Reverse in place : reverse « Array « Ruby






Reverse in place


a = [1,2,3]
p a.reverse!
p a                                  # => [3, 2, 1]

 








Related examples in the same category

1.Reverse the Order of the Array's Elements
2.The reverse method reverses the order of the elements in an array, returning a new array of elements, reversed