Ruby/Array/Pop

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

Версия от 18:01, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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