Ruby/Array/unshift
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 18:00, 13 сентября 2010
unshift prepends objects (one or more) to an array.
# It is like push but works on the beginning of an array, not the end. dates = [ 4, 5, 6, 7 ] # => [4, 5, 6, 7] dates.unshift 4 # => [4, 5, 6, 7] dates.unshift(2,3) # => [2, 3, 4, 5, 6, 7] puts dates