Skip to content

Instantly share code, notes, and snippets.

@offby1
Created June 15, 2012 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save offby1/2934518 to your computer and use it in GitHub Desktop.
Save offby1/2934518 to your computer and use it in GitHub Desktop.
def my_reverse(a)
reversed = []
a.each_index do |index|
new_index = a.size - index - 1
reversed[new_index] = a[index]
end
reversed
end
p my_reverse([1, 2, 3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment