glenn mcdonald says:
"The other way is to do:
myhash = Hash.new {|hash,key| hash[key] = []}
But this has the significant side-effect that asking about a key will create it, which renders has_key? fairly useless, so I avoid this method."
that does not in fact seem to be true.
irb(main):004:0> a = Hash.new {|hash,key| hash[key] = []}
=> {}
irb(main):005:0> a.has_key?(:key)
=> false
irb(main):006:0> a[:key]
=> []
irb(main):007:0> a.has_key?(:key)
=> true
Accessing the key will create it, as I would expect. Merely asking has_key? does not.