Ruby/Array/reverse
Материал из Wiki.crossplatform.ru
(Различия между версиями)
Версия 17:10, 26 мая 2010
Reverse in place
a = [1,2,3] p a.reverse! p a # => [3, 2, 1]
Reverse the Order of the Array"s Elements
x = [1, 2, 3] puts x.reverse.inspect
The reverse method reverses the order of the elements in an array, returning a new array of elements, reversed
%w[ one two three four five six seven eight nine ten ].reverse