Skip to content

Instantly share code, notes, and snippets.

@axiak
Created June 15, 2012 03:32
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 axiak/2934523 to your computer and use it in GitHub Desktop.
Save axiak/2934523 to your computer and use it in GitHub Desktop.
def my_reverse(a)
if a.empty?
[]
else
last = a.pop()
[last] + my_reverse(a)
end
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