Kotlin Sequences: Evaluated on Demand Keep the Natural Order of Operations
Code
fun main() = runBlocking {
sequenceOf(1, 2, 3)
.filter { out.printBlue("F:$it, "); it % 2 == 1 }
.map { out.printGreen("M:$it, "); it.toString() + "a"}
.forEach { out.print("E:$it, ") }
}
Command to reproduce:
gt.sandbox.checkout.commit 8b58878d5aa38a9ea4e1 \
&& cd "${GT_SANDBOX_REPO}" \
&& cmd.run.announce "./gradlew run --quiet"
Recorded output of command:
F:1, M:1, E:1a, F:2, F:3, M:3, E:3a,
Related
Backlinks