Q:

Kotlin coroutine won't compile without delay (suspend function?)

I was going through the Kotlin coroutine examples and was playing with this example.
fun main() = runBlocking {
    GlobalScope.launch {
        repeat(1000) {i->
            println("I'm sleeping $i ...")
            delay(500)
        }
    }
    delay(1300)
}

It works as the example expected, printing 3 times and terminating. How ever if the last line, delay(1300), is removed, the program will not recognise the main function and not compile. Why is this?
Replacing the last line with println() still compiles but only prints once.

A:

This happens because of return types.
main function should return Unit type.
In Kotlin

We can explicitly return a value from the lambda using the qualified return syntax. Otherwise, the value of the last expression is implicitly returned.

See Returning a value from a lambda expression
If the the delay call removed the outer lambda's(runBlocking) return type changed to Job (launch functions's return value) and main also returns Job. 
So it fails to run
fun main() = runBlocking {
    GlobalScope.launch {
        repeat(1000) {i->
            println("I'm sleeping $i ...")
            delay(500)
        }
    }
    delay(1300) // returns Unit, runBlocking also returns Unit and so does main
}

With delay removed:
fun main() = runBlocking {
    GlobalScope.launch {
        repeat(1000) {i->
            println("I'm sleeping $i ...")
            delay(500)
        }
    } // returns Job, runBlocking also returns Job and so does main
}

