Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveSupport::OrderedHash merge does not maintain order

#5390
>> a = ActiveSupport::OrderedHash[9, 2, 3, 1]
=> #<OrderedHash {3=>1, 9=>2}>
>> b = ActiveSupport::OrderedHash[7, 4]
=> #<OrderedHash {7=>4}>
>> c = b.merge(a)
=> #<OrderedHash {7=>4, 3=>1, 9=>2}>

Expected c to be {3=>1, 7=>4, 9=>2}. Is this by design?

Reported by Ronny Haryanto · August 17th, 2010 @ 07:00 AM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Ronny Haryanto
    Ronny Haryanto
    • Tag changed from activesupport orderedhash to 2.3.5, activesupport, orderedhash

    August 17th, 2010 @ 07:01 AM

  2. Ronny Haryanto
    Ronny Haryanto

    Forgot to mention version: 2.3.5. Ruby 1.8.7.

    August 17th, 2010 @ 07:02 AM

  3. Dimitar P. Dimitrov
    Dimitar P. Dimitrov

    The ActiveSupport::OrderedHash#inspect method is defined as follows in Rails 2.3.5:

    def inspect
      "#<OrderedHash #{super}>"
    end
    

    Therefore, the result of #inspect shouldn't be used to demonstrate how the hash is ordered. Please update your ticket report and use the #keys method, for example, to monitor the ordering of the keys.

    Moreover, I think that this initialization ActiveSupport::OrderedHash[9, 2, 3, 1] should produce the ordered hash @{ 9 => 2, 3 => 1 }@, not { 3 => 1, 9 => 2 } as is in your example.

    November 16th, 2010 @ 01:24 PM

  4. rails
    rails
    • State changed from new to open
    • Tag changed from 2.3.5, activesupport, orderedhash to 235, activesupport, orderedhash

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 18th, 2011 @ 12:00 AM

  5. rails
    rails
    • State changed from open to stale

    February 18th, 2011 @ 12:00 AM

  6. bingbing