Issue Details (XML | Word | Printable)

Key: GROOVY-1542
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Joachim Baumann
Reporter: Joachim Baumann
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Implement groupBy() for Maps as well as for Lists

Created: 01/Nov/06 03:47 PM   Updated: 26/Sep/07 08:33 PM
Component/s: groovy-jdk
Affects Version/s: 1.0-JSR-6
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

Environment: All


 Description  « Hide
The method groupBy() works only for lists. It should work for Maps as well.

The code for this functionality and the respective test is commented out in DefaultGroovyMethods and GroovyMethodsTest.

public static Map groupBy(Map self, Closure closure) {
final Map answer = new HashMap();
for (final Iterator iter = self.entrySet().iterator(); iter.hasNext() { groupCurrentElement(closure, answer, iter); }
return answer;
}



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Joachim Baumann added a comment - 04/Nov/06 09:49 AM
This functionality has been moved to post-1.0.

Joachim Baumann added a comment - 19/Jun/07 06:26 AM
This functionality is still commented

Joachim Baumann added a comment - 19/Jun/07 06:29 AM
Closures with one parameter (a Map.Entry) are allowed as well as closures with two parameters (key and value).