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.

[PATCH] ActiveSupport::OrderedHash#select does not preserve order

#5843

#select does not preserve order, though #find_all does.

    h = ActiveSupport::OrderedHash.new
    h['one'] = '1'
    h['two'] = '1'
    h['three'] = '1'
    
    h.find_all { true }
    # => [["one", "1"], ["two", "2"], ["three", "3"]]
    
    h.select { true }
    # => [["three", "3"], ["two", "2"], ["one", "1"]]

Reported by Gaius Centus Novus · October 20th, 2010 @ 12:30 AM

State: resolved
Milestone: 3.0.2
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Gaius Centus Novus
    Gaius Centus Novus

    This probably has something to do with Hash#select being defined in C (on C-based Rubies, at least), whereas Enumberable#select is just an alias for Enumberable#find_all. I guess OrderedHash < Hash is more powerful than a lowly alias in an included module.

    October 20th, 2010 @ 12:54 AM

  2. Gaius Centus Novus
    Gaius Centus Novus
    • Tag changed from 2.3.8, activesupport, orderedhash to 2.3.8, activesupport, orderedhash, patch

    October 20th, 2010 @ 01:05 AM

  3. Gaius Centus Novus
    Gaius Centus Novus
    • Title changed from ActiveSupport::OrderedHash#select does not preserve order to [PATCH] ActiveSupport::OrderedHash#select does not preserve order

    October 20th, 2010 @ 01:05 AM

  4. Aditya Sanghi
    Aditya Sanghi
    • State changed from new to verified
    • Milestone set to 3.0.2
    • Assigned user set to Santiago Pastorino
    • Importance changed from to Low

    +1 verified on 3.x/1.8.7 and 2.3.x/1.8.7

    Can you please provide the patch using git format-patch as specified on the contributor's guide though?

    The patch can be applied 2.3.10 branch as well as 3.0.2.

    October 20th, 2010 @ 09:41 AM

  5. Gaius Centus Novus
  6. Repository
  7. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    November 8th, 2010 @ 01:52 AM