Hash default value not being used [duplicate]
问题 This question already has answers here : Strange, unexpected behavior (disappearing/changing values) when using Hash default value, e.g. Hash.new([]) (4 answers) Closed 4 years ago . Today I tried the following snippets of code and I don't understand why I get different results between them. As far as I can understand they are the same. One uses the default value off Hash and the other snippet creates an empty array for the key before it'll be accessed. Anyone who understands what's going on?