Colton Idle
12/12/2023, 6:40 AMdata class Person(val phoneNumbers: List<String>, val metaData: String)
and then a list of people ( ie val people: List<Person>
) and I wanna map it into a single list of phone numbers. That's easy right?
people.flatMap{ it.phoneNumbers }
cool. that makes sense. but now I actually want to flat map it into a list of phone numbers, and with each phone number I want to attach a piece of metaData so the final type is List<PairString, String.
Any ideas?Riccardo Lippolis
12/12/2023, 6:43 AMpeople.flatMap { person -> person.phoneNumbers.map { it to person.metaData } }
?Riccardo Lippolis
12/12/2023, 6:43 AMperson.metaData to it
, depending on which side of the Pair the phonenumber should beColton Idle
12/12/2023, 6:47 AMColton Idle
12/12/2023, 6:49 AMJavier
12/12/2023, 8:15 AMColton Idle
12/12/2023, 8:22 AM