I'm doing the ruby koans exercises and am a bit confused about why the answers are such in the test_default_value_is_the_same_object method exercises. Below is the code:
def test_default_value_is_the_same_object
hash = Hash.new([])
hash[:one] << "uno"
hash[:two] << "dos"
assert_equal ["uno", "dos"], hash[:one]
assert_equal ["uno", "dos"], hash[:two]
assert_equal ["uno", "dos"], hash[:three]
end
I'm not sure why no matter what the key is, the value is always "uno" and "dos"? I thought when the key is one, the returned value should be "uno"; when key is "two", the returned value should be "dos". Why no matter what the keys are, the value is always an array?
Thank you and I'm looking forward to your answer!