What does this program print?

from Lambda expressions
Kotlin 2.4.10 beginner 2 min

What does this program print?

kotlin
fun sequence(): () -> Int {
    var next = 1
    return { next++ }
}

fun main() {
    val first = sequence()
    val alias = first
    val second = sequence()

    println(listOf(first(), alias(), second(), first()))
}
Open in playground
Report an error