You would like to group a list of students by last name and get the total number of groups. Which line of code accomplishes this, assuming you have a list of the Student data class? Data class Student(val firstName: String, val lastName: String)
A. Println(students.groupBy{ it.lastName }.count())
B. Println(students.groupBy{ it.lastName.first() }.fold().count())
C. Delegates.rx()
D. Println(students.groupingBy{ it.lastName.first() }.size())
Answer: Option A

Join The Discussion