So, I want to create a hash where any keys become arrays without having to separately declare them.
I therefore use
foo = Hash.new([])
=> {}
Then I can add items to keys that haven't been previously declared
foo[:bar] << 'Item 1'
=> ['Item 1']
There's just something odd about doing this. As when I call
foo
=> {}
to view the hash, it is empty. Even running
foo.keys
=> []
shows that it's empty. However, if I run
foo[:bar]
=> ['Item 1']
Please make it make sense.