Created
February 28, 2015 23:00
-
-
Save RJNY/2d3b41fe76813d805222 to your computer and use it in GitHub Desktop.
recursion.rb
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
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