-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

"pop"ing the first element of an Array is called "shift" ("unshift"  
being the operation of adding one element
in front of the array).

a = [1,2,3,4,5]
a.pop; a.shift;


Florian Gilcher

On Apr 8, 2008, at 6:30 PM, 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/.
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkf7n7oACgkQJA/zY0IIRZbJgQCfclWSiv3lsOeSsBdFFMqWWTDE
aAIAoI0HoqSXrYbAhsMWRrYKp/Ngx/O0
=S3a0
-----END PGP SIGNATURE-----