I want to create a coroutine method which has returning value.
For example)
fun funA() = async(CommonPool) {
return 1
}
fun funB() = async(CommonPool) {
return 2
}
fun sum() {
launch {
val total = funA().await() + funB().await()
}
}
If I want to return total in sum method, how should I do?
like,
fun sum(): Int {
launch {
val total = funA().await() + funB().await()
}
return total
}
question from:
https://stackoverflow.com/questions/47055804/kotlin-coroutines-with-returning-value 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…