Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created March 3, 2018 17:04
Show Gist options
  • Save apeiros/0b241060c4faca420c97ef21ef124c7b to your computer and use it in GitHub Desktop.
Save apeiros/0b241060c4faca420c97ef21ef124c7b to your computer and use it in GitHub Desktop.
dirs = ["A/B/C/", "A/B/D/", "A/B/E/", "A/F/G/"]
tree = {}
dirs.each do |dir|
current = tree
dir.split("/").each do |name|
current = (current[name] ||= {})
end
end
p tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment