AL
val second = secondList.toSet()
val result = firstList.filter { it.someProperty in second }
Size: a a a
AL
val second = secondList.toSet()
val result = firstList.filter { it.someProperty in second }
AN
AN
OY
AN
FN
val second = secondList.toSet()
val result = firstList.filter { it.someProperty in second }
FN
val second = secondList.toSet()
val result = firstList.filter { it.someProperty in second }
AL
AN
FN
OY
AN
OY
AN
AN
AL
fun main() {
val contacts = listOf(Contact(1), Contact(2), Contact(4))
val profiles = listOf(PublicProfile(1), PublicProfile(3), PublicProfile(4))
println(contacts)
populateContacts(contacts, profiles, { it.id }, { it.id })
println(contacts)
}
data class Contact(val id: Long, var publicProfile: PublicProfile? = null)
data class PublicProfile(val id: Long)
fun <T> populateContacts(contacts: List<Contact>, profiles: List<PublicProfile>, contactSelector: (Contact) -> T, profileSelector: (PublicProfile) -> T) {
val idToContacts = contacts.associateBy(contactSelector)
val idToProfiles = profiles.associateBy(profileSelector)
idToProfiles.forEach { (id, profile) -> idToContacts[id]?.let { it.publicProfile = profile }}
}
LS
AL
verify { foo.bar(any()) }
AL
LS
verify { foo.bar(any()) }