Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Is there an anonymous recursion alternative in Ruby? This is the best I could come up with which requires naming.
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