Skip to content

Instantly share code, notes, and snippets.

@jrochkind
Created March 30, 2010 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrochkind/349695 to your computer and use it in GitHub Desktop.
Save jrochkind/349695 to your computer and use it in GitHub Desktop.
irb(main):011:0> class AutoHash
irb(main):012:1> def initialize(*args)
irb(main):013:2> super(*args) {|hash, key| hash[key] = AutoHash.new }
irb(main):014:2> end
irb(main):015:1> end
=> nil
irb(main):016:0> a = AutoHash.new
=> {}
irb(main):017:0> a["foo"]["bar"]["baz"]
=> {}
irb(main):018:0> a["foo"]
=> {"bar"=>{"baz"=>{}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment