Rubyのクラスはオブジェクトなのでとても動的
ruby
クラスFooのインスタンスを作ってからFooの定義を書き換えたらそれ以前に作ったインスタンスの挙動も変わる
code:ruby
class Foo
def x
1
end
end
code:irb
=> :x
irb(main):011:0> obj = Foo.new
=> #<Foo:0x0000000153145420>
irb(main):012:0> obj.x
=> 1
code:ruby
class Foo
def x
2
end
end
code:irb
=> :x
irb(main):019:0> obj.x
=> 2
全てがオブジェクトなの本当に綺麗すぎるbiwa.icon
わかる~!!.iconbsahd.icon