From: Lionel Bouton Date: 2007-11-04T05:41:40+09:00 Subject: Re: x=[:some_key] does not work? Joshua Muheim wrote: > Ups I'm sorry, I messed things up because PHP uses [] for both arrays > and hashes. > > x = array(); > x["bla"]["some_key"] = true; > > Is Ruby not capable of doing this? > > x = {} > x[:bla][:some_key] = true > For a 2-dimensional Hash you can use: h = Hash.new({}) See the documentation of the initialize method of the Hash class. Here it basically tells the object to use a default value (an empty hash) for uninitialized keys. Lionel