Created
September 20, 2016 22:07
-
-
Save dsomel21/61a846ba087006d9e2a2e0fe0779e29c to your computer and use it in GitHub Desktop.
reverse array without reverse method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def reverse_array(array = []) | |
| reverse_array = [] | |
| (1..array.length).each { |n| | |
| reverse_array << array[n*-1] | |
| } | |
| puts reverse_array | |
| end | |
| reverse_array(["00", "01", "02", "03", "04", "05"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment