From: Martin DeMello Date: 2006-07-21T20:44:47+09:00 Subject: Re: opacity of magic enumerator (was: Re: Using .each with constructors) On 7/21/06, dblack@wobblini.net wrote: > On Fri, 21 Jul 2006, Logan Capaldo wrote: > > > > irb(main):001:0> RUBY_VERSION > > => "1.9.0" > > irb(main):002:0> a, b, c = 3.times.map { Object.new } > > => [#, #, #] > > Interesting.... That reveals that one of the problems with this magic > enumerator thing is that the method names weren't necessarily chosen > with this in mind, and don't work very well. 3.times.map very > strongly does *not* communicate a 0...3 mapping to me. My first If you think about it, though, the underlying problem is that 3.times passes a parameter into the block, which is what makes 3.times.map {|i| } nonintuitive. The plain 3.times.map {} doesn't suggest a 0...3 mapping, but rather an enumerator consisting of three "passes" which map naturally turns into a 3-object array. I predict that this *will* seem intuitive once magic enumerators have been around a while - note that it already reads perfectly as 3.times.collect martin