ary.pop â obj or nil
ary.pop(n) â new_ary
ary.pop(n) â new_ary
Instance Public methods
Removes the last element from self and returns it, or
nil if the array is empty.
If a number n is given, returns an array of the last
n elements (or less) just like array.slice!(-n,
n) does. See also #push for
the opposite effect.
a = [ "a", "b", "c", "d" ] a.pop #=> "d" a.pop(2) #=> ["b", "c"] a #=> ["a"]
Please login to continue.