Assuming you have
val list: List<Person> = listOf(Person("Ann", 19), Person("John", 23))
the function associateBywill probably satisfy you:
val map = list.associateBy({ it.name }, { it.age })
As stated in KDoc associateBy:
Returns a Mapcontaining the values provided valueTransformand indexed by the functions keySelectorapplied to the elements of this array.
If any two elements have the same key returned keySelector, the last one is added to the map.
The returned mapping preserves the iteration order of the record in the source array.
Iterable.