Mikhail
06/28/2022, 9:35 PM// in kotlin you can
suspend fun hi() {
suspend fun thing() {
}
thing()
}
// you can
suspend fun hi() {
val thing: suspend () -> Unit = {
}
thing()
}
// you can
fun hi() {
val thing = fun() {
}
thing()
}
// but you CAN'T
suspend fun hi() {
val thing = suspend fun() {
}
thing()
}
any specific reason?ephemient
06/29/2022, 5:01 AMval thing = suspend {
}
works fine, the grammar just doesn't allow for suspending anonymous functions right now. in fact, suspending function literals aren't a "real" thing either; suspend {}
isn't a keyword, but rather an inline function taking a lambda: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/suspend.htmlephemient
06/29/2022, 5:02 AMephemient
06/29/2022, 5:02 AMIlmir Usmanov [JB]
07/11/2022, 2:10 PM