2007/7/23, Fsormok Fsormok <fsormok / inbox.ru>: > > a = Hash.new{|h,k| h[k]=Hash.new &h.default_proc} > > > irb(main):026:0> require 'ostruct' > > irb(main):027:0> int = Hash.new{|h,k| h[k]=OpenStruct.new} > > >a = {} > > ==>{} > >a[1] = 1 > > ==>1 > >a[ [2,1] ] = 2 > > ==>2 > >a[ [2,2,3] ] = 4 > > ==>4 > >p a > >{[2, 2, 3]=>4, [2, 1]=>2, 1=>1} > > ==>nil > > Tanks for the replies. > > I'm just a little bit confused because in ruby everything is lean and > clean but when it comes to hashes of hashes it gets kind of complicated. > For me it looks like ruby has another "concept" of solving such things. Its this what you are looking for? $ ruby <<XXX > miss = lambda {|h,k| h[k] = Hash.new(&miss)} > hash = Hash.new(&miss) > hash[1][2]=3 > hash[4]=5 > p hash > XXX {1=>{2=>3}, 4=>5} Kind regards robert