Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val heroes = listOf(
- Hero("The Captain", 60, MALE),
- Hero("Frenchy", 42, MALE),
- Hero("The Kid", 9, null),
- Hero("Lady Lauren", 29, FEMALE),
- Hero("First Mate", 29, MALE),
- Hero("Sir Stephen", 37, MALE))
- val mapByAge: Map<Int, List<Hero>> =
- heroes.groupBy { it.age }
- val (age, group) = mapByAge.maxBy { (_, group) ->
- group.size
- }!!
- println(age)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement