What is the output?
fun main() {
val s = (1..6).asSequence()
.map { it * 2 }
.filter { it > 5 }
.take(2)
println(s.toList())
}
Try it in the online Kotlin Playground →
[spoiler title="Solution"]
Answer:
[6, 8]
Explanation:
Sequences evaluate lazily, processing elements one at a time.
[/spoiler]