Skip to content
Browse files

AS guides: reword the docs of Enumerable#group_by

  • Loading branch information...
1 parent edb5401 commit 00f49c74e8354e393ed4ffd6bfa8beb657c8920d @fxn fxn committed Jul 13, 2010
Showing with 2 additions and 4 deletions.
  1. +2 −4 railties/guides/source/active_support_core_extensions.textile
View
6 railties/guides/source/active_support_core_extensions.textile
@@ -1840,17 +1840,15 @@ h3. Extensions to +Enumerable+
h4. +group_by+
-Ruby 1.8.7 and up define +group_by+, and Active Support does it for previous versions.
-
-This iterator takes a block and builds an ordered hash with its return values as keys. Each key is mapped to the array of elements for which the block returned that value:
+Active Support redefines +group_by+ in Ruby 1.8.7 so that it returns an ordered hash as in 1.9:
<ruby>
entries_by_surname_initial = address_book.group_by do |entry|
entry.surname.at(0).upcase
end
</ruby>
-WARNING. Active Support redefines +group_by+ in Ruby 1.8.7 so that it still returns an ordered hash.
+Distinct block return values are added to the hash as they come, so that's the resulting order.
NOTE: Defined in +active_support/core_ext/enumerable.rb+.

0 comments on commit 00f49c7

Please sign in to comment.
Something went wrong with that request. Please try again.