From: Joel VanderWerf Date: 2009-04-29T10:07:25+09:00 Subject: Re: dynamically calling methods that require a block Barun Singh wrote: > Is it possible to call methods that require block inputs dynamically > without resorting to "eval"? For example, consider: > > a = [1,2,3] > a.detect{|x| x > 2} > > I want to know if it's possible to do something like the following (this > doesn't work): > > a.send(:detect, {|x| x > 2}) > > I'm using Ruby 1.8.6 > > Thanks.. Just pass the block to the send method as you normally would pass a block: a.send(:detect, &proc {|x| x > 2}) => 3 a.send(:detect) {|x| x > 2} => 3 -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407