selfとはインスタンス自身の参照である
class Test def initialize @num = 5 end def cp self end attr_accessor :num end test = Test.new test2 = test.cp test2.num=3 pp test.num #=>3 pp test2.num #=>3
より明らか
class Test def initialize @num = 5 end def cp self end attr_accessor :num end test = Test.new test2 = test.cp test2.num=3 pp test.num #=>3 pp test2.num #=>3
より明らか