i make beer, music, and code. sometimes in that order. @aberant on twitter

ruby drive-by: autovivification

need multi-level hashes in a hurry? (assumes 1.9)

h = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)}
h["foo"]["bar"]["baz"] = 42
h["foo"] #=> {"bar"=>{"baz"=>42}} 
Comments
blog comments powered by Disqus