From: Robert Klemme Date: 2004-05-05T01:48:56+09:00 Subject: Re: model for my problem (network simulator) "Gergely Kontra" schrieb im Newsbeitrag news:20040504125533.GB27180@mlabdial.hit.bme.hu... > On 0504, Robert Klemme wrote: > > Nope, that's not the same: > > irb(main):001:0> h=Hash.new {[]} > > irb(main):002:0> h[1] > > irb(main):003:0> h > > => {} > > irb(main):004:0> h=Hash.new {|h,k| h[k]=[]} > > irb(main):005:0> h[1] > > irb(main):006:0> h > > => {1=>[]} > > Your solution makes the idiom "h[key] << something" unusable since all > > those arrays never make it into the hash. > > Oh, yes, I run into the problem, and this is the weird case, where > h[key] << something and h[key] <<= something is different... Note also that h[key] << something is more efficient since it does only one hash lookup and no hash update. Regards robert