Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created March 3, 2018 17:04
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