In Ruby, when I call reverse
method on an array, it doesn't reverse sort the array completely.
array = [5, 4, 9, 8, 7, 1, 2]
array.reverse # => [2, 1, 7, 8, 9, 4, 5]
I'm unable to understand what operation it's performing on the array.
In Ruby, when I call reverse
method on an array, it doesn't reverse sort the array completely.
array = [5, 4, 9, 8, 7, 1, 2]
array.reverse # => [2, 1, 7, 8, 9, 4, 5]
I'm unable to understand what operation it's performing on the array.
Note:
See how it works: