Additional (hopefully less hopeless) questions abo...
# getting-started
d
Additional (hopefully less hopeless) questions about context receivers, this time related to lambdas. Is it possible to indicate that a lambda body needs a context without creating an intermediate val?
Copy code
{ functionThatNeedsAccountContext() } // how to indicate that this needs Account?

val myfun: context(Account) () -> ... = { functionThatNeedsAccountContext() } // this works but I would like to avoid the intermediate val
(I need to pass the lambda as an argument in a parametrized test case that lacks typing so the context can't be inferred.)
e
does
Copy code
context(Account) { functionThatNeedsAccountContext() }
work like other modifiers?
d
That's what I've tried (I could have mentioned it...) but no.
y
You could define some helpers a-la `suspend`:
Copy code
fun <C1, R> context(lambda: context(C1) () -> R) = lambda
d
Yeah, that's what I've tried as well. See my next question 🙂