O
oinkoink
On the quickstart tutorial on the Ruby homepage,
http://www.ruby-lang.org/en/quickstart/3/ , it says,
"In Ruby, you can open a class up again and modify it. That doesn't
change any objects that already exist, but it does affect any new
objects you create." This is incorrect. For example:
irb(main):001:0> class FooClass; end
nil
irb(main):002:0> sally = FooClass.new
#<FooClass:0xb7e0b214>
irb(main):003:0> class FooClass; def foo; puts "bar"; end; end
nil
irb(main):004:0> sally.foo
bar
nil
Changing a class changes the objects of that class which already exist
(which is pretty cool).
Regards, Bret
Bret Jolly
http://www.ruby-lang.org/en/quickstart/3/ , it says,
"In Ruby, you can open a class up again and modify it. That doesn't
change any objects that already exist, but it does affect any new
objects you create." This is incorrect. For example:
irb(main):001:0> class FooClass; end
nil
irb(main):002:0> sally = FooClass.new
#<FooClass:0xb7e0b214>
irb(main):003:0> class FooClass; def foo; puts "bar"; end; end
nil
irb(main):004:0> sally.foo
bar
nil
Changing a class changes the objects of that class which already exist
(which is pretty cool).
Regards, Bret
Bret Jolly