This project is archived and is in readonly mode.

#1676 ✓resolved
Brandon Keepers

OrderedHash mishandles keys

Reported by Brandon Keepers | December 31st, 2008 @ 03:46 PM | in 2.x

The latest implementation of OrderedHash does not behave as expected when it comes to managing keys in several situations. For example, #merge! doesn't work:

>> h = ActiveSupport::OrderedHash.new
>> h.merge! :a => 1, :b => 2
=> {:a=>1, :b=>2}
>> h.keys
=> []
>> h.inspect
=> "{:a=>1, :b=>2}"

Also, when calling non-destructive methods like #reject it mangles the keys:

>> h = ActiveSupport::OrderedHash.new
>> h[:a] = 1
>> h[:b] = 2
>> h2 = h.reject {|k,v| k == :a }
=> {:b=>2}
>> h.inspect
=> "{:a=>1, :b=>2}"
>> h.keys
=> [:b]

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages