I make a new hash with a default value of an empty array.
h = Hash.new([])
I push a value into the hash where the key is
'a'
.h['a'].push(1243)
h
is empty.h # => {}
h['a']
returns the expected value.h['a'] # => [1243]
h.keys
returns an empty array.h.keys # => []
If I initialize the hash in step one with Hash.new {|h,k| h[k]=[]}
then expected values are returned.