Skip to content

Instantly share code, notes, and snippets.

@ericntd
Last active August 15, 2020 13:54
Show Gist options
  • Save ericntd/d0ba21fafd3b36859b7f971ad23da718 to your computer and use it in GitHub Desktop.
Save ericntd/d0ba21fafd3b36859b7f971ad23da718 to your computer and use it in GitHub Desktop.
// prepare variable employees which is a list of Employee object
// Same as Task 0
employees.groupingBy { it.department }
.eachCount()
.forEach { (s, i) ->
println("there are $i employees for department $s")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment