From: Robert Klemme Date: 2012-02-08T00:15:47+09:00 Subject: Re: Using _ like in Scala? On Tue, Feb 7, 2012 at 1:00 PM, Josh Cheek wrote: > I do this sometimes, but I do it like this > > %w[apple banana orange].each &method(:puts) > # >> apple > # >> banana > # >> orange > > This one isn't too bad. +1 > It can get kind of gross when you need to get the > method from elsewhere, though: > > %w[apple banana orange].each &Kernel.method(:puts) > # >> apple > # >> banana > # >> orange > > I wouldn't mind if there were cleaner ways of accessing the methods > themselves (some kind of syntax). I'd make it explicit as long as this "cleaner syntax" is lacking. > Although what I'd really like would be a syntax for naming inline blocks, > then my editor could fold the block body inside the name, something like > %w[apple banana orange].each display > > And it would expand to something like > %w[apple banana orange].each { |display -> fruit| puts fruit } How would the above be derived from the line further up? > But never found anything I was very happy with. Actually in this case "puts fruits" would be the best solution. ;-) Did anybody suggest it before? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/