article banner

Exercise: What is stored by a continuation?

Consider you started the following code in debug mode, and you are currently stopped at the line marked with // HERE. What is stored in the continuation variable?

import kotlin.coroutines.* suspend fun a() { val c = 12345 suspendCoroutine { it.resume(Unit) } suspendCoroutine { continuation -> continuation.resume(c) // HERE } println(c) } suspend fun main() { val a = "ABC" val b = listOf(1, 2, 3) println(b) a() println(a) }

Once you are done with the exercise, you can check your solution here.