When to use coroutineScope vs supervisorScope?
问题 Can someone explain what exactly is the difference between these two? When do you use one over the other? Thanks in advance. 回答1: The best way to explain the difference is to explain the mechanism of coroutineScope . Consider this code: suspend fun main() = println(compute()) suspend fun compute(): String = coroutineScope { val color = async { delay(60_000); "purple" } val height = async<Double> { delay(100); throw HttpException() } "A %s box %.1f inches tall".format(color.await(), height