Skip to content

Instantly share code, notes, and snippets.

@RJNY
Created February 28, 2015 23:00
Show Gist options
  • Save RJNY/2d3b41fe76813d805222 to your computer and use it in GitHub Desktop.
Save RJNY/2d3b41fe76813d805222 to your computer and use it in GitHub Desktop.
recursion.rb
def recursion(arg, arg2=[]) #5
arg2 << arg
p arg2
if arg <= 0 #false
puts "arg: #{arg}, finished" #no
return
end
puts "before: #{arg}" # before: 5
recursion(arg-1, arg2) # recursion(4) ...brb
puts "after: #{arg}" #5
end
recursion(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment