Array.pop
Signature
array.pop #=> object or nil
array.pop removes and returns the last object from array. nil is returned if array is empty (which is not a good test for an empty array since the last object of the array could itself be nil).
Examples
stack = []
stack.pop #=> nil
stack.push(1,2,3) #=> [1, 2, 3]
stack.pop #=> 3
stack #=> [1, 2]
stack.push(nil) #=> [1, 2, nil]
stack.pop #=> nil
Documentation Reference
Ruby version 1.8.6
- Log in to post comments
