Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardKotlinthe Continuation interfaceSingle-choice MCQ

Consider this hand-rolled bridge. Assuming registerCallback invokes its argument asynchronously on another thread later, what is the bug?

suspend fun await(): String = suspendCoroutine { cont -> var result: String? = null registerCallback { value -> result = value } if (result != null) cont.resume(result!!) else cont.resume("timeout") }