-
-
Save havenwood/aeaf09529627db51871d60eaae2000dc to your computer and use it in GitHub Desktop.
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 recur(value = [], &block) | |
value << block.call(value.size) | |
return value if value.size > 10 | |
recur(value, &block) | |
end | |
recur { |n| n + 1 } | |
#=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] |
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 recur(value = [], lamb) | |
value << lamb.call(value.size) | |
return value if value.size > 10 | |
recur(value, lamb) | |
end | |
recur -> n { n + 1 } | |
#=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment