July 2018
Intermediate to advanced
242 pages
8h 6m
English
With the following flatMap operation, the getLecturesOfCoursesWithSubscribedStudents() function is transforms the collection of the Student type objects into the collection of the Course type by merging elements of the Student.courses: Collection<Course> property:
getStudents() .flatMap { student: Student -> student.courses }
As the result, the preceding code returns the Collection<Course> type. The collection returned by the flatMap operation contains a set of all the courses all of the students (obtained from the getStudents() function) are subscribed to.
Next, in order to remove duplicated courses, we append the chain of operations with the distinct() function. Then, we use the map() function. It is responsible for transforming ...
Read now
Unlock full access