Skip to content

Instantly share code, notes, and snippets.

@dscataglini
Created August 19, 2010 01:23
Show Gist options
  • Save dscataglini/536728 to your computer and use it in GitHub Desktop.
Save dscataglini/536728 to your computer and use it in GitHub Desktop.
hash = Hash.new(&(p = lambda{|hsh, key| hsh[key] = Hash.new(&p)}))
# now you can do this
hash[:this][:is][:very][:cool] = "Yeah baby, yeah ... "
#=> "Yeah baby, yeah ... "
hash
#=> {:this=>{:is=>{:very=>{:cool=>"Yeah baby, yeah ... "}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment