In kotlin, if you have ```scope.launch { fooSus...
# coroutines
c
In kotlin, if you have
Copy code
scope.launch {
  fooSuspendedFun()
  barSuspendedFun()
}
will barSuspendedFun wait until the completion of fooSuspendedFun, or do you need to use something to await the return of the first function?
j
barSuspendedFun
will wait for
fooSuspendedFun
. The idea of Kotlin coroutines design is that if it looks like a regular function call, it behaves somewhat like a regular function call (suspend or not). So imagine it behaves similarly to seeing 2 regular function calls in a row
e
the only functions to do leave the linear control flow that should take a
CoroutineScope
parameter, such as
launch
and its receiver
if a function doesn't take a
CoroutineScope
(and doesn't break structured concurrency by using
GlobalScope
or creating its own scope), then it is guaranteed to complete before the next function
c
Thank you both 🙂