-
-
Save apeiros/a81b1ff315a517bbaaac7f5f8d00492e 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 breadcrumb(h, stack=[]) | |
h.each_key do |key| | |
puts((stack+[key]).join(" -> ")) | |
end | |
h.each do |k, v| | |
breadcrumb(v, stack+[k]) | |
end | |
nil | |
end | |
data = {"A"=>{"B"=>{"C"=>{}, "D"=>{}, "E"=>{}}, "F"=>{"G"=>{}}}} | |
breadcrumb(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment