Created
July 31, 2016 20:30
-
-
Save bitops/46814832c2a33097eb3c5ba2f7890f52 to your computer and use it in GitHub Desktop.
a recursive function in ruby that takes a block
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 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