Could anyone tell me the correct syntax for declar...
# coroutines
f
Could anyone tell me the correct syntax for declaring anonymous suspend lambda with parameters? val foo =suspend { a, b -> c } doesn’t seem to work
j
I think you have to specify the parameter types explicitly or the function type as a whole
e
Copy code
val foo: suspend (A, B) -> C = { a, b -> c }
f
Thanks!
Is this documented somewhere?
z
I think you can also use anonymous function syntax
Copy code
val foo = suspend fun(a: A, b: B): C { return c }
e
nope :(
z
You’re right, I thought that worked 😢
e
I expect it should work after https://youtrack.jetbrains.com/issue/KT-22765/Introduce-suspend-modifier-for-lambdas is implemented, but that's been a long time…
z
Kotlin will also be able to calculate the meaning of life as soon as the ticket for adding that function to the stdlib is closed 😅
😂 2