Blow Your Stack
# A stack is a LIFO (last in, first out) structure.
# You can use an array like a stack by using the push and pop methods from the Array class.
fruit = %w[ apple orange banana ]
fruit.pop # => "banana"
p fruit # => ["apple", "orange" ]
fruit.push "mango"
p fruit # => ["apple", "orange", "mango"]
Related examples in the same category