tmg
05/20/2020, 8:52 AMasync
executed inside a coroutineScope
finishes before the block exits? (i mean, coroutineScope
waits async
, just like it does for launch
)marstran
05/20/2020, 8:54 AMgildor
05/20/2020, 9:02 AMtmg
05/20/2020, 9:28 AMval foo: Deffered<Int>
corotineScope {
foo = async { bar() }
}
foo * 2 // foo is smart casted to Int
gildor
05/20/2020, 9:28 AMbar() * 2
val foo: Deffered<Int>
corotineScope {
foo = async { bar() }
}
foo.await() * 2
tmg
05/20/2020, 9:33 AMawait
not being needed as async
was called in the block scopegildor
05/20/2020, 9:38 AMtmg
05/20/2020, 9:41 AMbut only if you start this async using scope of coroutineScope, not some external scopebecaus eby your comment, at that stage the
async
has finished, so it can actually be smart casted
and as I said, I just don’t see why you need corotineScope or async for this exampleSorry, could have been a better example, image `bar`takes a while, and there are more stuff in the
coroutineScope
block, including other coroutines being launch/asyncgildor
05/20/2020, 9:42 AM