Question : how to reverse array in ruby
Answered by : dizzy-dog-g8p8trqkpc8p
# ruby
arr = [0,1,2]
# reverse
arr_rev = arr.reverse
# arr_rev = [2,1,0]; arr = [0,1,2]
arr == arr_rev.reverse!
# true
# ! immediately changes the value and stores it back to the variable
Source : | Last Update : Sat, 01 Jan 22
Question : reverse order array ruby
Answered by : bruno-leite
[1,2,3,4].reverse
# [4,3,2,1]
Source : | Last Update : Wed, 01 Jun 22