https://kotlinlang.org logo
Title
x

xxfast

07/19/2021, 11:17 PM
Accidentally typed in this
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
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.
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