M
Mark Dodwell
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
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