From: li shoubo Date: 2012-10-15T20:27:32+09:00 Subject: Re: About define_method can you give me more details? Or it is a rule that I can not use yield in define_method method to define a new one? Robert Klemme wrote in post #1079874: > On Mon, Oct 15, 2012 at 9:49 AM, Ryan Davis > wrote: >> >> On Oct 15, 2012, at 00:15 , Robert Klemme wrote: >> >>> $ ruby -e 'module Kernel;define_method(foo) { yield 1 };end;foo {|x| p x}' >>> -e:1:in `': undefined local variable or method `foo' >> >> you meant :foo > > Yes, of course. Thanks for catching that. Then we get > > $ ruby -e 'module Kernel;define_method(:foo) { yield 1 };end;foo {|x| p > x}' > -e:1:in `block in ': no block given (yield) > (LocalJumpError) > from -e:1:in `
' > > Kind regards > > robert -- Posted via http://www.ruby-forum.com/.