groovy

Implement groupBy() for Maps as well as for Lists

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-6
  • Fix Version/s: 1.1-beta-2
  • Component/s: groovy-jdk
  • Labels:
    None
  • Environment:
    All
  • Number of attachments :
    0

Description

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;
}

Activity

Hide
Joachim Baumann added a comment -

This functionality has been moved to post-1.0.

Show
Joachim Baumann added a comment - This functionality has been moved to post-1.0.
Hide
Joachim Baumann added a comment -

This functionality is still commented

Show
Joachim Baumann added a comment - This functionality is still commented
Hide
Joachim Baumann added a comment -

Closures with one parameter (a Map.Entry) are allowed as well as closures with two parameters (key and value).

Show
Joachim Baumann added a comment - Closures with one parameter (a Map.Entry) are allowed as well as closures with two parameters (key and value).

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: