Created
June 13, 2015 03:51
-
-
Save stalcottsmith/8baf5437da80f79470a1 to your computer and use it in GitHub Desktop.
Is there an anonymous recursion alternative in Ruby? This is the best I could come up with which requires naming.
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
func = -> (node, func) { | |
node.children.each do |node| | |
# do something | |
func.call(node, func) | |
end | |
} | |
func.call(root, func) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment