Any ideas to make this code more idiomatic?
# codereview
h
Any ideas to make this code more idiomatic?
b
1.
sessionSpeakerIdList.forEach { speakerId ->
seems unused, moreover you will add duplicates to sessionModel.speakerList 2. Why
sessionList.map
? It converts your list to List<Unit>. you can use onEach, if you just want to apply op on each item
It can be something like that:
Copy code
val speakerById :List<SpeakersModel> = getSpeakersInfo().associateBy { it.id }
val sessionList : List<SessionsModel> = snapshots.toObjects<SessionsModel>()
sessionList.onEach { sessionModel ->
    sessionModel.speakerList = sessionModel.speaker_id.mapNotNull {speakerById[it]}
            }
h
sessionSpeakerIdList.forEach{speakerId ->}
am getting an array of speakerId and for eachbid am getting the speaker details
b
You don't use
speakerId
then
h
Seen from your example, thanks for the help