Skip to content

Instantly share code, notes, and snippets.

@babedev
Last active March 25, 2018 08:48
Show Gist options
  • Save babedev/ed331046811be1311dda36c6d51a2d3c to your computer and use it in GitHub Desktop.
Save babedev/ed331046811be1311dda36c6d51a2d3c to your computer and use it in GitHub Desktop.
List vs Sequence no terminal operation
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