If I initialize an array of hashes and then assign to 1 element in the array, why are all elements effectively assigned to?
e = Array.new(4, {})
e[0][:test] = 5
e
Now e looks like this, why?:
[{:test=>5}, {:test=>5}, {:test=>5}, {:test=>5}]
If I initialize an array of hashes and then assign to 1 element in the array, why are all elements effectively assigned to?
e = Array.new(4, {})
e[0][:test] = 5
e
Now e looks like this, why?:
[{:test=>5}, {:test=>5}, {:test=>5}, {:test=>5}]