Created
March 14, 2020 14:41
-
-
Save magdamiu/5b20f9b13a16233dc6763e100285a713 to your computer and use it in GitHub Desktop.
Transform functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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