Return to Snippet

Revision: 8865
at October 11, 2008 06:49 by pmd


Updated Code
# From: http://www.ruby-forum.com/topic/111524
# Author: Daniel Martin

a = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }

a[2][1]=2
a[2][2][3]=4
a[3][1][1][1]=1

p  a     #=> {2=>{1=>2, 2=>{3=>4}}, 3=>{1=>{1=>{1=>1}}}}

Revision: 8864
at October 11, 2008 06:44 by pmd


Initial Code


Initial URL
http://www.ruby-forum.com/topic/111524

Initial Description


Initial Title
Create nested hashes

Initial Tags


Initial Language
Ruby