ruby hash api gives the answer: the key should not be changed while it is used as a key.
I assume that the hash interval is computed for a and used for a quick search (because the key should not change, the hash is always the same). Therefore, when you do h[a] , it does not find a match ([1,2,3] .hash! = [1,2,3,4] .hash), and when you do h[[1,2,3]] , hashed, and the object does not match ([1,2,3]! = [1,2,3,4]).
The fix is ββto use object_id as a key because it does not change, h[a.object_id] = 12 will return 12 when the changes are changed. Of course, this has the disadvantage that h[[1,2,3].object_id] will not return 12.
source share