Thanks for pointing this out. I did indeed miss an important point. Regards, Morton On Jul 18, 2006, at 9:18 AM, ts wrote: >>>>>> "M" == Morton Goldberg <m_goldberg / ameritech.net> writes: > > M> # Each instance will have its own version of method "bar". > > no, not really > > moulon% cat b.rb > #!/usr/bin/ruby > class Foo > > def Foo.make_bar(&block) > define_method(:bar, &block) > end > > # Each instance will have its own version of method "bar". > def initialize(&block) > Foo.make_bar(&block) > end > > end > > f = Foo.new {puts "foobar"} > f.bar > Foo.new {|s| printf "%s %s\n", s, s}.bar("foobar") > f.bar("xxxxx") > moulon% > > moulon% ./b.rb > foobar > foobar foobar > xxxxx xxxxx > moulon% > > > Guy Decoux >