To reverse an array in ruby, you can use either the .reverse or .reverse! method.
.reverse returns a new array with elements in reverse order:
main.rb73 chars3 lines
.reverse! reverses the elements in place, modifying the original array:
main.rb34 chars2 lines
If you want a non-destructive way to reverse an array, use .reverse instead.
gistlibby LogSnag