This project is archived and is in readonly mode.
OrderedHash should not pretend to be an Array
Reported by Greg Borenstein | January 19th, 2009 @ 07:54 PM | in 2.x
The ActiveSupport::OrderedHash that comes back from such methods as #group_by looks, in script/console, indistinguishable from an Array, which makes me want to call methods on it like an array, which leads to pain and confusion. Attached is a tiny patch that adds an #inspect method to ActiveSupport::OrderedHash that produces output that looks like this: http://pastie.org/364930 Goal is to make it clear that you're dealing with an OrderedHash, but also to encourage you to think of it as having hash-like rather than array-like indexing.
Comments and changes to this ticket
-
Pratik January 19th, 2009 @ 09:27 PM
- Title changed from [PATCH] OrderedHash should not pretend to be an Array to OrderedHash should not pretend to be an Array
-
Rick January 20th, 2009 @ 07:05 PM
- Tag set to activesupport, patch
- Assigned user set to Rick
I'm the one that badgered greg over twitter into submitting this patch :) However, #to_hash isn't working for me for some reason. However, since the hash is ordered in Ruby 1.9, I want to change #inspect to match ruby 1.9's Hash.
-
Repository January 26th, 2009 @ 03:29 AM
- State changed from new to committed
(from [f4bf318db061daa8c6ebb2b700fd15034e031310]) add an inspect method to OrderedHash to make it clear that it is not a species of Array
Signed-off-by: Michael Koziarski michael@koziarski.com [#1782 state:committed] http://github.com/rails/rails/co...
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
- 1782 OrderedHash should not pretend to be an Array Signed-off-by: Michael Koziarski michael@koziarski.com [#...