Ruby Method of the Day - 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
1 2 3 4 5 6 7 |
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
