Reverse the Order of the Array's Elements : reverse « Array « Ruby






Reverse the Order of the Array's Elements


x = [1, 2, 3]
puts x.reverse.inspect

 

Related examples in the same category

1.The reverse method reverses the order of the elements in an array, returning a new array of elements, reversed
2.Reverse in place