Will this (on Android) print Finished before Hi, o...
# coroutines
d
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
Repl and scratch do not have main dispatcher
d
Oh... funny there's no error, although in Kotlin Playground there was that error.
g
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
There is no error probably, because app finished before coroutine is dispatched