Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lyleunderwood/883631 to your computer and use it in GitHub Desktop.
Save lyleunderwood/883631 to your computer and use it in GitHub Desktop.
ActiveSupport::HashWithIndifferentAccess#merge bug
Regular Hash behavior:
irb(main):023:0> a = {"one"=>"aye", "two"=>"bee"}
=> {"one"=>"aye", "two"=>"bee"}
irb(main):024:0> a.merge(a) {|k,v| 1}
=> {"one"=>1, "two"=>1}
Crazy HashWithIndifferentAccess behavior:
irb(main):025:0> b = ActiveSupport::HashWithIndifferentAccess.new("one"=>"aye", "two"=>"bee")
=> {"one"=>"aye", "two"=>"bee"}
irb(main):026:0> b.merge(b) {|k,v| 1}
=> {"one"=>"aye", "two"=>"bee"}
^^^
Bug?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment