Last active
March 25, 2018 08:48
-
-
Save babedev/ed331046811be1311dda36c6d51a2d3c to your computer and use it in GitHub Desktop.
List vs Sequence no terminal operation
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
println("List ====> ") | |
listOf(1, 2, 3) | |
.filter { | |
println("Filter: $it") | |
it % 2 == 0 | |
} | |
.map { | |
println("Map: $it") | |
it | |
} | |
println("Stream ====> ") | |
listOf(1, 2, 3).stream() | |
.filter { | |
println("Filter: $it") | |
it % 2 == 0 | |
} | |
.map { | |
println("Map: $it") | |
it | |
} | |
println("Sequence ====> ") | |
sequenceOf(1, 2, 3) | |
.filter { | |
println("Filter: $it") | |
it % 2 == 0 | |
} | |
.map { | |
println("Map: $it") | |
it | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment