Changeset 8516
- Timestamp:
- 12/31/07 21:30:17 (9 months ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/enumerable.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r8505 r8516 1 1 *SVN* 2 3 * Changed the implementation of Enumerable#group_by to use a double array approach instead of a hash such that the insert order is honored [DHH/Marcel] 2 4 3 5 * remove multiple enumerations from ActiveSupport::JSON#convert_json_to_yaml when dealing with date/time values. [rick] trunk/activesupport/lib/active_support/core_ext/enumerable.rb
r7474 r8516 16 16 # "2006-02-23 -> Transcript" 17 17 def group_by 18 inject({}) do |groups, element| 19 (groups[yield(element)] ||= []) << element 18 inject([]) do |groups, element| 19 value = yield(element) 20 if (last_group = groups.last) && last_group.first == value 21 last_group.last << element 22 else 23 groups << [value, [element]] 24 end 20 25 groups 21 26 end