method
pop
pop()
public
Register or
log in
to add new notes.
Ariejan -
November 18, 2008
9 thanks
Pop for last, Shift for first
If you want to pop the first element instead of the last one, use shift .
Mange -
October 5, 2009
1 thank
Using argument version in ruby < 1.8.7
The argument to this method was added in Ruby 1.8.7. If you want to use this form in an earlier version, you must instead use the slice! method.
It is mentioned up in the docs, but here it is again for reference:
# Ruby >= 1.8.7 p = list.pop(n) # Ruby < 1.8.7 p = list.slice!(-n, n)