Created
June 9, 2013 01:50
-
-
Save theverything/5737286 to your computer and use it in GitHub Desktop.
reverse an array
This file contains 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
array = [] | |
100.times { |i| array << i } | |
def my_reverse(array = []) | |
size = array.size | |
b = array.dup | |
b.reverse_each do |i| | |
b << i | |
end | |
b.drop(size) | |
end | |
my_reverse array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment