July 2018
Intermediate to advanced
242 pages
8h 6m
English
We can also modify our map building operation to a more concise form by using the mapValues function:
fun getCoursesWithSubscribedStudents(): Map<Course, List<Student>> = getStudents() .flatMap { student -> student.courses.map { course -> course to student } } .groupBy { (course, _) -> course } .mapValues { (course, courseStudentPairs) -> courseStudentPairs.map { it -> it.second } }
Read now
Unlock full access