Jacob Fugal wrote:
> On 7/21/06, transfire / gmail.com <transfire / gmail.com> wrote:
> > But why does #times return the receiver in the first place? That can't
> > possible be anywhere near as useful as the alternative.... Just return
> > the collection.
>
> The primary reason I can see is that Fixnum#times is frequently used
> with a fairly large valued receiver. Such as in benchmarking:
>
>   10000.times{ ... }
>
> Do you really want that to generate a 10000 element array? Probably
> not. I too can see (and desire) the utility of a returned collection,
> but we lose the beauty of Fixnum#times as a replacement for the purely
> incremental while loop.

Ouch. Good point. I like enumerators! ;-)

T.