From: Benoit Daloze Date: 2010-09-18T08:47:55+09:00 Subject: [ruby-core:32468] Re: [ruby-core:32466] Re: [ruby-core:32461] Re: [ruby-core:32453] Why doesn’t Enumerable define a #last method? On 18 September 2010 00:00, Nikolai Weibull wrote: > On Fri, Sep 17, 2010 at 17:04, Benoit Daloze wrote: >> On 17 September 2010 12:19, Nikolai Weibull wrote: >>> Why doesn�t Enumerable define a #last method that�s analogous to #first? > >> Well, I believe #last will always be very inefficient. > > I don�t care about efficiency. �I care about is expressiveness. Then your "ugly, ugly implementation" should be all you need. If you only care about expressiveness, I believe defining your own methods for yourself is the best. But if you want to propose or ask "Why doesn�t Enumerable define a #last method that�s analogous to #first?", please read the answers of the others, and not only the "expressiveness" part. Quick answer: It may be analogous in the terms, but it would be completely different in the implementation. An Enumerator can be easily traversed in the sense it is meant, but hardly in the other one. And the (n) #last element(s) of an infinite enumerator does not make sense. As you only care of a finite set, why do you not use Array#last ?