From: "Florian Groß" Date: 2005-04-10T01:26:15+09:00 Subject: Re: Array#last_index jzakiya@mail.com wrote: > array.last returns the value of the last array element. > > In many instances it is necessary to get the index value > of the last array element. This is necessary in many > sorting and searching algorithms, especially where the > arrays are dynamically changing in size. You can do it like: > > class Array > def last_index; self.length - 1 end > end > > But this is slower than necessary, because array.last > already computes/knows what the last index value is, > and thus the mechanism already exists to get this info. > > I would really like to see this method added to class Array. > It is a nice complement to Array#last, and aides performance. Can you not just use -1 as the index?