Skip to content

Instantly share code, notes, and snippets.

@bitops
Created July 31, 2016 20:30
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 bitops/46814832c2a33097eb3c5ba2f7890f52 to your computer and use it in GitHub Desktop.
Save bitops/46814832c2a33097eb3c5ba2f7890f52 to your computer and use it in GitHub Desktop.
a recursive function in ruby that takes a block
def foo(n, &block)
if n > 0
yield(n)
foo(n - 1, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment