prev = 0 var cur = 1 while (true) { print(“Next") val next = prev + cur yield(next) / / suspension point prev = cur cur = next } print("End") / / unreachable code }.take(8).forEach { print(" $it ") } / / Output: Start 1 Next 1 Next 2 Next 3 Next 5 Next 8 Next 13 Next 21
https:/ /github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines- informal.md Full kotlinx.coroutines API: http:/ /kotlin.github.io/kotlinx.coroutines Coroutines guide by Roman ELizarov: https:/ /github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md