From: Robert Klemme Date: 2010-09-06T23:52:09+09:00 Subject: Re: Odd functional programming question On Mon, Sep 6, 2010 at 4:11 PM, Brian Candler wrote: > On Mon, Sep 06, 2010 at 10:50:35PM +0900, Peter Hickman wrote: >> Any other ideas gratefully received. > > That's The Right Way To Do It. For methods which take a block you'll need to > pass that through, and it's slightly more efficient to use symbols instead > of strings (if you pass a string to send, it will have to convert it to a > symbol for you). > > def X(text, todo, *args, &blk) >  text.send(todo, *args, &blk) > end > > puts X("abcdefgh", :downcase) > puts X("abcdefgh", :each_byte) { |i| puts i } Actually I'd say _this_ definition of X is completely superfluous since it does not add anything to #send and so only helps obfuscate code and slows down execution. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/