foo=Object.new def foo.a "foo.a" end p foo.a # => "foo.a"
class Foo
def Foo.foo
"Foo.foo"
end
def self.bar ## 余談だが、この文脈ではself==class Fooなので、こういう書き方も出来ます。
"self.bar"
end
end
p Foo.foo # => "Foo.foo"
p Foo.bar # => "self.bar"このページを編集 (2441 bytes)
| 以下の 8 ページから参照されています。 |
This page has been visited 8393 times.