Will this (on Android) print Finished before Hi, or Hi before finished... it seems like repl and scratch files don't work for this
Copy code
val dispatcher = Dispatchers.Main.immediate
val scope = CoroutineScope(dispatcher)
fun main() {
println("Started.")
scope.launch { delay(30); println("Hi!") }
println("Finished.")
}
g
gildor
11/26/2019, 1:47 PM
Repl and scratch do not have main dispatcher
d
dave08
11/26/2019, 1:48 PM
Oh... funny there's no error, although in Kotlin Playground there was that error.
g
gildor
11/26/2019, 1:48 PM
Hi will be printed after finish because you have delay (of course it will be on real Android, just for command line app main method and app would finish before Hi
gildor
11/26/2019, 1:49 PM
There is no error probably, because app finished before coroutine is dispatched