ruby

allocateとnew

rubyのallocateとnewの違い class Blog def initialize p 'initialize!' end end a = Blog.allocate p '*' * 10 b = Blog.new 結果 "**********" "initialize!!" まとめ allocateはインスタンスを生成する。 newはallocateを生成した後initializeを使い初期…