The reverse function in Ruby is used to reverse the input array into another new array and keep the input array as it is before.
Here Array is the input array whose elements are to be reversed.
Parameters: This function does not accept any parameters.
Returns: the another new array of reversed elements of the input array.
["d", "c", "b", "a"]   [2, 1] ["Shita", "Geeta", "Ram"]
["a", "b", "c", "d"]   [1, 2] ["Ram", "Geeta", "Shita"]
Note: In the above example, it can be seen that after calling the reverse function it reverse the original input array into another array and keep the original array as it is before.
- Ruby | reverse! function
- Ruby | Array reverse!() function
- Ruby | Array reverse() function
- Ruby | String reverse Method
- Ruby | Set add? function
- Ruby | at() function
- Ruby | pop() function
- Ruby | Numeric zero? function
- Ruby | DateTime sec() function
- Ruby | Set divide() function
- Ruby | DateTime second() function
- Ruby | Complex abs function
- Ruby | Regexp new() function
- Ruby | Time eql?() function
- Ruby | abbrev function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.