Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Transform functions
//map
println(languagesList.map { it.town })
println(languagesList.mapIndexed { index, language -> index to language.town })
//distinct
println(languagesList.map { it.town }.distinct())
//associate(), associateBy()
println(languagesList.associate { it.name to it.town })
println(languagesList.associateBy({ it.name }, { it.company }))
//groupBy()
println(languagesList.groupBy { it.company })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment