From: Jonas Delfs Date: 2002-03-28T00:49:22+09:00 Subject: Re: Hash.new(Hash.new) doesn't use Hash.new as default value "Yukihiro Matsumoto" skrev i en meddelelse news:1017241889.836825.26588.nullmailer@ev.netlab.jp... > In message "Re: Hash.new(Hash.new) doesn't use Hash.new as default value" > on 02/03/27, ts writes: > > | With 1.7 you'll have the possibility to write > | > | Hash.new { Hash.new } > | > | and each times a key is not defined, ruby will evaluate the block, the > | result of the block will be stored in the Hash and ruby will do what you > | want. > > It does not store the evaluated default value. Should it? If not it will not be possible to do var['index']['anotherIndex'] = 'value' without having defined var['index'] to be a Hash first, so in this case: yes. But, I can also think of situations where it would be very unhandy if an index gets a value just by accessing it. Maybe we can provide an optional argument to 'new'? -- Mvh./Best Regards Jonas Delfs, http://delfs.dk