4.特異メソッド
#特異メソッド
class Foo
def Foo.test
print "this is foo\n"
end
end
Foo.test #=>this is foo
#通常
class Foo
def test
print "this is foo\n"
end
end
o = Foo.new
o.test #=>this is foo
クラスの特異メソッドをクラスメソッドと呼びます。
○Rubyとオブジェクト指向についてアウトプットしてみる○
1.メッセージ ~オブジェクトは「問いかけたらきちんと返事をしてくれる」~
2.継承とは
3.メソッドの実行
4.特異メソッド
5.特異クラス
6.オーバーライド
7.Mixin(include)
8.Mixin(extend)
9.委譲