Remove entries from an array one by one. : Pop « Array « Ruby






Remove entries from an array one by one.


# arrays act as a "first in, first out" system 
# popping is the process of retrieving items from the end of the array and removing them at the same time.

x = []
x << "Word"
puts x
x << "Play"
puts x
x << "Fun"
puts x
puts x.pop
puts x
puts x.pop
puts x
puts x.length
puts x

 








Related examples in the same category