Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlincoroutines basics launch asyncSingle-choice MCQ

In a coroutine, what is the difference between calling an async builder's result with .await() immediately versus storing the Deferred and awaiting later?

suspend fun load(): Int { val a = coroutineScope { async { compute1() }.await() } val b = coroutineScope { val d1 = async { compute1() } val d2 = async { compute2() } d1.await() + d2.await() } return a + b }