Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. val heroes = listOf(
  2. Hero("The Captain", 60, MALE),
  3. Hero("Frenchy", 42, MALE),
  4. Hero("The Kid", 9, null),
  5. Hero("Lady Lauren", 29, FEMALE),
  6. Hero("First Mate", 29, MALE),
  7. Hero("Sir Stephen", 37, MALE))
  8.  
  9. val mapByAge: Map<Int, List<Hero>> =
  10. heroes.groupBy { it.age }
  11. val (age, group) = mapByAge.maxBy { (_, group) ->
  12. group.size
  13. }!!
  14. println(age)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement