From: diego scataglini Date: 2007-07-11T22:57:01+09:00 Subject: Re: Polymorphic Code Thank you for the correction =) Diego Scataglini On Jul 11, 2007, at 9:19 AM, Phrogz wrote: > On Jul 8, 3:31 pm, diego scataglini wrote: >> I believe that changes to a class don't modify its already existing >> instances. But you can always add and remove behavior of an object. > > C:\>irb > irb(main):001:0> class Foo; def sq(x) x*x end; end > irb(main):002:0> f = Foo.new > irb(main):003:0> f.sq( 12 ) > => 144 > > irb(main):004:0> class Foo; def double(x) x+x end; end > irb(main):005:0> f.double( 21 ) > => 42 > > irb(main):006:0> class Foo; def sq(x) x*x*x end; end > irb(main):007:0> f.sq( 12 ) > => 1728 > >