This project is archived and is in readonly mode.
[PATCH] ActiveSupport::OrderedHash#each* methods don't return self
Reported by ghorner | February 2nd, 2011 @ 03:21 PM
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.
Comments and changes to this ticket
-
ghorner February 2nd, 2011 @ 03:25 PM
- 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
-
Repository February 2nd, 2011 @ 03:42 PM
- State changed from new to resolved
(from [9a0f43d3c1dd35fde074af6cc2825ae1872aabef]) OrderedHash#each* methods return self like Hash does [#6364 state:resolved]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/9a0f43d3c1dd35fde074af6cc2825...
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
Tags
Referenced by
- 6364 [PATCH] ActiveSupport::OrderedHash#each* methods don't return self (from [9a0f43d3c1dd35fde074af6cc2825ae1872aabef]) Ordered...