I want to create a coroutine method which has returning value.
For example)
fun funA() = async(CommonPool) {
return 1
}
fun funB() = async(Commo
I edit your work, i change the funA and funB into a suspend function and i created a function for sum operator and i call on main function, this the example :
suspend fun funA(): Int{
return 1
}
suspend fun funB(): Int {
return 2
}
fun sum() = runBlocking{
val resultSum = async { funA.await() + funB.await() }
return resultSum
}
fun main() = runBlocking{
val result = async { sum() }
println("Your result: ${result.await()}")
}
Hope it will help