Hi! I thought `suspend` lambdas could be used just...
# coroutines
j
Hi! I thought
suspend
lambdas could be used just like normal lambdas. Why then is this not allowed?:
Copy code
fun main() {
    val f = suspend { i: Long ->
        delay(i)
    }

    runBlocking {
        f(1000L)
    }
}
h
You must specify the type in the declaration, not in the usage block
Copy code
val f: suspend (Long) -> Unit = { i: Long ->
        delay(i)
    }

    runBlocking {
        f(1000L)
    }
j
Ahh, ok, so when using the
suspend
keyword together with a parameterised lambda, the variable needs to be annotated? Contrast with a normal lambda where this is perfectly fine:
Copy code
val f = { l: Long ->
   Thread.sleep(l)
}