You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem:
Accessing a HashWithIndifferentAccess does not return the the same object
that is stored in the hash (i.e. equal?) causing unexpected results:
hash = HashWithIndifferentAccess.new {|h, k| h[k] = []}
hash[:a] << 1 # => [1]
hash[:a] # => [], expected [1]
The cause:
When a block is provided to generate default values the generated values
are duped if they are arrays. The duped value is stored in the hash but
the original value is returned when the hash is accessed.
The fix:
The duping is there for allowing frozen arrays containing hashes to be
modified. The fix restricts the duping to this case. Note that if default
function generates a frozen array an error will be raised on assignment
before and after the patch.
Closesrails#3811
0 commit comments