Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created May 28, 2015 15:20
Show Gist options
  • Save leejarvis/496c2017488be2d1588c to your computer and use it in GitHub Desktop.
Save leejarvis/496c2017488be2d1588c to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def append(array, n)
return array if n < 0
append(array, n-1)
puts "shit #{n}"
end
p append([], 3)
#
append([], 3) #=> print 3 / Runs last
-> append([], 2) #=> print 2 / Runs third
-> append([], 1) #=> print 1 / Runs second
-> append([], 0) #=> return / Runs first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment