gropingBy + eachCountで実現。
listOf(1, 2, 3, 1, 1, 2).groupingBy { it }.eachCount()
=> {1=3, 2=2, 3=1}
eachCountのリファレンスが詳しい。
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/each-count.html
Go to list of users who liked
More than 5 years have passed since last update.
gropingBy + eachCountで実現。
listOf(1, 2, 3, 1, 1, 2).groupingBy { it }.eachCount()
=> {1=3, 2=2, 3=1}
eachCountのリファレンスが詳しい。
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/each-count.html
Register as a new user and use Qiita more conveniently
Go to list of users who liked