Joel VanderWerf wrote: > Daniel Finnie wrote: >> What I want to do is have 2 nested hashes, the outer hash returning a >> new hash on an unknown key and the inner hash returning a space on an >> unknown key. > > value = Hash.new {|h,k| h[k] = Hash.new {|h1,k1| h1[k1] = " "}} > > p value[5][6] # ==> " " > value[5][6] = "H" > p value # ==> {5=>{6=>"H"}} > Another option, in case you don't want all those empty strings cluttering up your hash: value = Hash.new {|h,k| h[k] = Hash.new {" "}} p value[5][6] # ==> " " p value # ==> {5=>{}} value[5][6] = "H" p value # ==> {5=>{6=>"H"}} # But, with this variation, beware: value[5][7] << "add some characters after the space" p value[5][7] # ==> " " -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407