Anonymous suspending functions


#1

I have a class which takes a function as parameter, which will then only be called from coroutines. But since the compiler doesn’t know that, I can’t call delay inside of it.

The docs state “anonymous suspending functions are currently not supported”. Are they planned?


#2

nevermind I just found out that the launch function uses an anonymous suspend function, are the docs wrong?


#3

Doc is right. Anonymous suspending function is suspend fun() { ... } which is not supported. However, suspending functional types like suspend () -> Unit and suspending lambdas are supported, which enables functions like launch which can take suspending lambda like launch { ... }