On 10/16/07, David Flanagan <david / davidflanagan.com> wrote:
> Rick DeNatale wrote:
> >> If that is too radical a change, I suggest that Range.first be extended
> >> to accept an integer argument.  And in that case, it should delegate to
> >> Enumerable.first. That is, even if (1..0).first continues to return 1,
> >> (1..0).first(1) should correctly return [].
> >
> > +1/2 on this one, I guess.  Note that this won't work for all ranges,
> > for example:
> >
> > (1.5..10.7).first(2)
> >
> > Since float ranges aren't enumerable.
> >
>
> But it will work in the sense that it will be consistent with the each
> method.  Now that first is a method of Enumerable, anyone calling it on
> an Enumerable object like a Range is going to expect it to be based on
> each.  If each raises an exception (as it does for float ranges) then
> first will raise an exception.

Correct, it was more of an observation than an objection.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/