What does this print?
fun main() {
val out = (1..6).asSequence()
.map { it * 3 }
.take(3)
.toList()
println(out)
}
Try it in the online Kotlin Playground →
[spoiler title="Solution"]
Answer:
[3, 6, 9]
Explanation:
Creates lazy sequence 1-6, multiplies each by 3, but take(3) truncates to first three only. toList() converts from lazy.
[/spoiler]