12件ヒット
[1-12件を表示]
(0.282秒)
検索結果
先頭1件
-
ruby 1
. 8 . 3 feature (37.0) -
ruby 1.8.3 feature *((<ruby 1.8 feature>)) *((<ruby 1.8.2 feature>))
...y-talk:146894>))
$ cat test_dlg.rb
foo = Object.new
foo2 = SimpleDelegator.new(foo)
def foo.bar
puts "bar"
end
foo2.bar
$ ruby-1.8.2 -r delegate test_dlg.rb
test_dlg.rb:6: undefined method `bar' for #<Object:0x4021b0a0> (NoMethodError)
$ ruby-1.......t [ruby] [new]
: Module#class_variable_set [ruby] [new]
クラスメソッドから((<変数と定数/クラス変数>))にアクセスするための
((<Module#class_variable_get|Module/class_variable_get>)) と
((<Module#class_variable_set|Module/class_variable_set>)) が
追加され......def Fred.foo
@@foo = 101 #=> @@foo は Fred クラスのクラス変数ではない。
end
def Fred.foo_foo
class_variable_set(:@@foo, 101) # self が Fred クラス自身であることに注意。クラス変数 @@foo に値をセットする。
end...