Created
May 5, 2022 15:04
-
-
Save AndroidPoet/6ac499c1a8a58d1d09e8e62b91549d7a to your computer and use it in GitHub Desktop.
MapVsFilter
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
val intList = mutableListOf(1, 2, 3, 4, 5, 6, 7) | |
val filtered = intList.filter { | |
it % 2 == 0 | |
} | |
println(filtered)///[2, 4, 6] | |
val mapped = intList.map { | |
it * it | |
} | |
println(mapped)//[1, 4, 9, 16, 25, 36, 49] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment