Daniele B
08/13/2020, 2:24 PMdiesieben07
08/13/2020, 2:29 PMval languages = listOf<A>()
val populations = listOf<B>()
val populationsByCountry = populations.associateBy { it.country }
val result = languages.map { C(it.country, it.language, checkNotNull(populationsByCountry[it.country]).population) }
Daniele B
08/13/2020, 2:34 PMnanodeath
08/13/2020, 3:08 PM(populationsByCountry.keySet + languagesByCountry.keySet).map { ... }
. then you can error if an item is missing from either collection.