https://kotlinlang.org logo
#coroutines
Title
# coroutines
x

xxfast

07/19/2021, 11:17 PM
Accidentally typed in this
Copy code
suspend { //some suspending calls here }
and this compiles just fine. Is this the same as
runBlocking{}
🤔
e

ephemient

07/19/2021, 11:46 PM
no, it creates a suspend lambda
similar to how
{ ... }
creates a lambda
x

xxfast

07/20/2021, 1:09 AM
Copy code
val x: suspend () -> Unit = suspend {  }
ah it all makes sense with type inference
e

ephemient

07/20/2021, 1:36 AM
suspend can be inferred, e.g.
Copy code
val x: suspend () -> Unit = { }
so it's rare that you need it on the lambda itself, but there might be some cases where it's useful for disambiguation
3 Views