Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0-JSR-6
-
None
Description
Regroup elements according to a closure criteria inside a map index by the value of the criteria.
def expected = [Integer: [1, 2], String: ["a", "b"], BigDecimal: [3.5, 4.6]]
def list = [1, "a", 2, "b", 3.5, 4.6]
def result = list.groupBy
{ it.class } assert [1, 2] == result[Integer]
assert ["a", "b"] == result[String]
assert [3.5, 4.6] == result[BigDecimal]
assert 3 == result.size()