Vinícius Santos
06/11/2021, 12:47 PMviewModelScope.launch {
launch { a = one() }
launch { b = two() }
print(a+b)
}
Shabinder Singh
06/11/2021, 12:48 PMephemient
06/11/2021, 5:04 PMephemient
06/11/2021, 5:05 PMcoroutineScope {
launch { a = one() }
launch { b = two() }
}
print(a + b)
ephemient
06/11/2021, 5:07 PMvar a/b
Rafs
06/13/2021, 10:24 AMval sum = async{one()}.await() + async{two()}.await()
ephemient
06/13/2021, 4:42 PMephemient
06/13/2021, 4:46 PMval sum = listOf(async { one() }, async { two() }).sumOf { it.await() }
if you really wanted to avoid temporary values for some reason… otherwise
val a = async { one() }
val b = async { two() }
val sum = a.await() + b.await()
works straightforwardlyVinícius Santos
06/13/2021, 5:35 PM