On Apr 8, 11:30 am, Mark Dodwell <s... / mkdynamic.co.uk> 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 viahttp://www.ruby-forum.com/.

a.shift
a.pop
?