From: Joel VanderWerf Date: 2001-12-31T11:51:50+09:00 Subject: [ruby-talk:29787] Re: Ruby multi-dimensional Hash question? "Crandall, Jeff W" wrote: > > Ruby Guru's: > > I want to dynamically(while reading data in from a file) create a > multi-dimensional hash array. Something like the following: > > myHash[a1[][a2[index_number>] = a3[] One way ( kinda crude, but simple), is: (h[a1[index]] ||= {})[a2[index]] = ... The ||= effectively means "assign if left side is nil". There are fancier ways, like PerlValue: http://www.ruby-lang.org/en/raa-list.rhtml?name=PerlValue