دنبال کننده ها

۱۳۹۶ آذر ۱۰, جمعه

When lambda parameters must be noinline in Kotlin?

[ad_1]



I often encounter errors in Kotlin inlined functions where lambda parameters must be marked noinline. Other times, lambda parameters seem to work OK. I've read the Kotlin documentation of inline functions, and it seems like this is the operative passage explaining the rule:




Inlinable lambdas can only be called inside the inline functions or
passed as inlinable arguments, but noinline ones can be manipulated in
any way we like: stored in fields, passed around etc.




I'm having trouble unpacking those concepts. Specifically, I'm not sure I fully understand the things I can't do (including what all is in the "etc.") with an inlined lambda -- in other words, the things that would disqualify it from being inlined. Is there a good reference or more explanation/examples of uses that disqualify a Kotlin lambda parameter from being inlined?




[ad_2]

لینک منبع