Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.8.1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
This functionality is already available via Collection#sum(Closure) as shown here:
def nums = 1..10
def squaresAndCubesOfEvens = nums.sum{ it % 2 ? [] : [it**2, it**3] }
assert squaresAndCubesOfEvens == [4, 8, 16, 64, 36, 216, 64, 512, 100, 1000]
however the name sum is not intuitive in all scenarios and sum is not always the most efficient was to concatenate such lists as it directs through the Groovy 'plus' operator to allow custom overriding of 'plus'.
The intention is to provide a collectMany "alias" for sum which is more efficient and has naming similar to C#'s Enumerable.SelectMany operator.