List Info

Thread: Error in Ruby quickstart tutorial




Error in Ruby quickstart tutorial
user name
2006-10-04 20:00:11
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


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )