From: Paul Novak Date: 2007-06-14T02:45:05+09:00 Subject: Re: define_method to define a method to pass a block to another method On Jun 13, 9:40 am, "John J. Franey" wrote: > I would like to define the following method, func, using define_method > instead of def: > > def func(i, &block) > wblock(i, &block) > end > > def wblock(i, &block) > yield(i) > end > > The following didn't work: > > # syntax error > define_method('func') do |i,&block| > wblock(i, &block) > end > > # ruby expects a second parameter, not a block > define_method('func') do |i,block| > wblock(i, &block) > end > > Any ideas? > > Thanks > -- > View this message in context:http://www.nabble.com/define_method-to-define-a-method-to-pass-a-bloc... > Sent from the ruby-talk mailing list archive at Nabble.com. Sorry I don't have time to work out a more complete answer, but check this out: http://innig.net/software/ruby/closures-in-ruby.rb it is the best exploration of Ruby closures that I've seen. Regards, Paul.