From: Charles Oliver Nutter Date: 2009-05-14T22:36:26+09:00 Subject: Re: [bikeshed] Syntactic sugar idea Daniel DeLorme wrote: > It seems that often an object will be passed into a block only to invoke > a method of that object: > arr.map{ |obj| obj.some_method } > > So I had the (weird? stupid?) thought that it would be nice to have some > syntactic sugar like this: > arr.map{ .some_method } > > Does that make any sense? Groovy has this in the form of the "it" magic variable: [1,2,3].each {puts it} While I absolutely hate the moniker "it" the idea itself has grown on me. Perhaps something more scala-like: [1,2,3].each {puts _} Or a pseudo-global: [1,2,3].each {puts $it} I hacked "it" to work in JRuby once recently, and it's not difficult. - Charlie