public
Created

Auto-creating nested hashes via recursive proc

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4
hash = lambda { |h, k| h[k] = Hash.new &hash }
x = Hash.new &hash
x[1][2][3][4][5] = 6
x #=> {1=>{2=>{3=>{4=>{5=>6}}}}}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.