If contacts is of type List<Contact>
you can do the following:
val numOccurencesMap = contacts.groupingBy { it.name }.eachCount()
numOccurencesMap
will be of type Map<String, Int>
.
If contacts is of type List<Contact>
you can do the following:
val numOccurencesMap = contacts.groupingBy { it.name }.eachCount()
numOccurencesMap
will be of type Map<String, Int>
.