Created
July 6, 2020 02:46
-
-
Save ericntd/efd40f99f579a84ca56ee222ccf650de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
employees.groupingBy { it.department } | |
.aggregate { key, acc: Int?, element, isFirstElement -> | |
return@aggregate if (isFirstElement) { | |
0 + element.salary | |
} else { | |
acc!! + element.salary | |
} | |
} | |
.map { | |
println("Total salary for department ${it.key} is ${it.value}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment