Ruby/Array/Pop

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

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