From: Simon Strandgaard Date: 2006-01-03T07:03:48+09:00 Subject: Re: Implicit block parameter? On 1/2/06, Ross Bamford wrote: > On Mon, 02 Jan 2006 20:20:30 -0000, I wrote: > > > Before I used Ruby, I used Groovy. In some ways they are (well, were > > anyway) quite similar, and one feature that I found cool in Groovy that > > I often miss in Ruby is the implicit (/default/whatever?) block > > parameter, 'it': > > > > [1,2,3].each { puts it } how about? class Array alias :each1 :each def each(&b) each1{|i| b.call($i = i) } end end %w(a b c).each{p $i} #-> "a" "b" "c" -- Simon Strandgaard