Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created March 5, 2018 19:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apeiros/a81b1ff315a517bbaaac7f5f8d00492e to your computer and use it in GitHub Desktop.
Save apeiros/a81b1ff315a517bbaaac7f5f8d00492e to your computer and use it in GitHub Desktop.
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