I expected:
h = Hash.new([])
h['a'] << 'b'
h['a'] << 'c'
h # => {}
to give {'a' => ['b','c']}
, not an empty hash.
I also found out that the insert operation targets the default value, because after the code above it is euqal to ['b','c']
:
h.default # => ['b','c']
I am looking for an explanation on why it does not work and how to do it optimally so it works.