On Tue, 25 May 2004 22:41:42 +0900, 
Gavin Sinclair <gsinclair / soyabean.com.au> wrote:

> On Tuesday, May 25, 2004, 8:20:00 PM, Mauricio wrote:
> 
> > I'd rather keep Integer#times as it is, and use the 
> >   a, b, c = (1..3).map{[]} 
> > idiom; I don't think the use case deserves polluting the language (in the
> > case of 'of', by being too generic) or a potentially big performance hit,
> > for a minimal gain.
> 
> I certainly agree that that idiom is clear enough and we don't need to
> address the "problem" at hand.  And your notes about performance are
> well made.
> 
> I guess something like this would qualify for 'extensions' if there
> was enough interest and a really good name.  Perhaps n.map { ... } as
> a shortcut for (0...n).map { ... } is suitable, but I've realised by
> now that my intuition is not often widely shared :)

If you were going to do that....

>> class Integer
>>   alias each times
>>   include Enumerable
>>   end
=> Integer
>> 5.map { [] }
=> [[], [], [], [], []]
>> 5.select { |n| n % 2 == 0 }
=> [0, 2, 4]
>>

Jason Creighton