From: ts Date: 2006-07-18T22:18:29+09:00 Subject: Re: Strange behaviour - Instantiating an object and giving it a block to be used as a method body >>>>> "M" == Morton Goldberg 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