Created
August 15, 2020 13:56
-
-
Save ericntd/29cd3c8a52f0d8de1812972e1c3f326e 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
// prepare variable employees which is a list of Employee object | |
// Same as Task 0 | |
employees.groupingBy { it.department } | |
.fold(initialValue = 0) { total, employee -> total + employee.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