method

pop

Importance_2
Ruby latest stable (v1_8_6_287) - 1 note - Class: Array
pop() public

Removes the last element from self and returns it, or nil if the array is empty.

   a = [ "a", "m", "z" ]
   a.pop   #=> "z"
   a       #=> ["a", "m"]
Show source
Register or log in to add new notes.
November 18, 2008
0 thanks

Pop for last, Shift for first

If you want to pop the first element instead of the last one, use shift .