# getting-started

Colton Idle

12/12/2023, 6:40 AM
Not sure if I'm missing something here but I have
data 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 AM
something like:
people.flatMap { person -> { it to person.metaData } }
person.metaData to it
, depending on which side of the Pair the phonenumber should be

Colton Idle

12/12/2023, 6:47 AM
Phone number should be on the left, and meta data on the right. Hm. Could it be as simple as a map inside of the flatmap!? let me try 🙏
yeah, i think that just about does it. thank you so much @Riccardo Lippolis i wouldn't have thought of that. i was just looking for a different operator in general. lol
👍 1


12/12/2023, 8:15 AM
Do you have repeated phones? If not, probably you should go with a Map and use any group API

Colton Idle

12/12/2023, 8:22 AM
id have to check actually, but thanks for the idea Javier