Hash magic
1.9.3p286 :001 > h = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)}
=> {}
1.9.3p286 :002 > h[1][2][3]=:test
=> :test
1.9.3p286 :003 > h
=> {1=>{2=>{3=>:test}}}
Written by Timur Valeev
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#