From: Xavier Noria Date: 2008-04-09T01:41:38+09:00 Subject: Re: Remove first and last items from array On Apr 8, 2008, at 18:30 , Mark Dodwell wrote: > 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! } Hehe. I think the natural idiom is a slice: a[1..-2] It returns an array as long as a.length > 0. -- fxn