Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moonmaster9000/919771 to your computer and use it in GitHub Desktop.
Save moonmaster9000/919771 to your computer and use it in GitHub Desktop.
def my_reverse( a )
reversed = []
length_a = a.length
for counter in Array.new( length_a )
last = a.pop
reversed.push( last )
end
reversed
end
a = [1,2,3,4]
b = my_reverse a
puts b.inspect
#==> [4, 3, 2, 1]
puts a.inspect
#==> []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment