From: Shawn Anderson Date: 2008-04-09T01:59:57+09:00 Subject: Re: Remove first and last items from array ------=_Part_20529_28374224.1207673994716 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline a.shift a.pop This reads a little better to me. You don't want to collect the items at all right? /Shawn On Tue, Apr 8, 2008 at 9:30 AM, Mark Dodwell wrote: > Hi, > > I need to remove the first and last items in an array (which may have 1, > 2 or more items so the resulting array after removal may be empty). I > came up with this: > > a = [1,2,3,4,5] > 2.times { a.pop; a.reverse! } > > It works well, but do you think that there is a slightly less obscure > way!? > > Cheers, > > ~ Mark > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_20529_28374224.1207673994716--