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#each* methods don't return self

#6364

I noticed while using Enumerable#group_by that ordered hashes don't act like normal hashes. Specifically, their each* methods return their keys instead of self:

>> h = ActiveSupport::OrderedHash.new.merge :a =>1, :b =>2
=> #<OrderedHash {:a=>1, :b=>2}>
>> h.each { }
=> [:a, :b]
>> h.each_key { }
=> [:a, :b]
>> h.each_value { }
=> [:a, :b]

Breaking compatibility with Hash is not good as it leads to unexpected and broken behavior. It also seems these methods were made with the intention of Hash compatibility.

Reported by ghorner · February 2nd, 2011 @ 03:21 PM

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

Activity

  1. ghorner
    ghorner
    • Title changed from ActiveSupport::OrderedHash#each* methods don't return self to [PATCH] ActiveSupport::OrderedHash#each* methods don't return self
    • Tag set to patch

    February 2nd, 2011 @ 03:25 PM

  2. Repository