From: Urabe Shyouhei Date: 2010-09-17T20:32:53+09:00 Subject: [ruby-core:32457] Re: [ruby-core:32456] Re: [ruby-core:32455] Re: Why doesn’t Enumerable define a #last method? (2010/09/17 20:10), Nikolai Weibull wrote: > On Fri, Sep 17, 2010 at 13:00, Urabe Shyouhei wrote: >> (2010/09/17 19:19), Nikolai Weibull wrote: >>> Why doesn���t Enumerable define a #last method that���s analogous to #first? >> >> Simplest counterexample is [1].cycle.last > > I wouldn���t say that that example counters the validity of having #last > in Enumerable. I mean, sure, there���s obviously no last element in > this example, but neither can #all? be answered: > > [1].cycle.all?{ |i| i == 1 } > > even though it has an obvious answer. OK, a bit more complicated example. require "stringio" s = StringIO.new "foobar" e = s.enum_for :each_char s.seek 6 e.last # => nil for your definition, but not sure if it should be? The point is, an Enumerable's last may not exist for various reasons.