Ruby/Array/shift
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 18:01, 13 сентября 2010
Using shift and unshift
# To remove an element from an array is with the shift method. # This method returns the first element of an array (nil if the array is empty), and then removes the element, shifting all other elements down by one. dates = [ 4, 5, 6, 7 ] # => [4, 5, 6, 7] dates.shift # => 4 p dates # => [5, 6, 7]