Skip to content

Instantly share code, notes, and snippets.

@dtoma
Last active January 2, 2016 09:29
Show Gist options
  • Save dtoma/8283583 to your computer and use it in GitHub Desktop.
Save dtoma/8283583 to your computer and use it in GitHub Desktop.
Trick for infinite-level hash
# (cf. https://www.ruby-forum.com/topic/140570#624505)
lazy = lambda { |h,k| h[k] = Hash.new(&lazy) }
my_hash = Hash.new(&lazy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment