From: Robert Klemme Date: 2009-06-19T23:35:04+09:00 Subject: Re: hash of hash? 2009/6/19 Florian Weingarten : > Jeroen Lodewijks wrote: >> class Hashhash >> ... >> end >> >> out = ah["T"][9] >> ... >> test.rb:5: undefined method `[]' for # > > Hi Jeroen, > > I think you have to explicitly define a [] method for your class > (and a []= method, if you want to write values with this syntax too). Alternatively Jeroen can simply create a Hash with a default_proc which will recursively insert Hashes: irb(main):001:0> ha = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)} => {} irb(main):002:0> ha[1][2][3] => {} irb(main):003:0> ha[1][2][3]=123 => 123 irb(main):004:0> ha => {1=>{2=>{3=>123}}} irb(main):005:0> Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/