Whenever I try to evaluate expression that uses context of lambda in kotlin, it says that it's not captured. How do I deal with it? For example in ktor I want to see what kind of context data is available when I debug post endpoint, but whenever I evaluate expression using
this
it says
this@post is not captured
k
karelpeeters
04/15/2019, 11:34 AM
In the end lambdas are pretty much normal objects, and by default they don't store all of the surrounding state because that would be terrible for eg. GC. What you can do is actually use what you want to capture in the lambda, maybe something like