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