我读过this question篇,但我有一个关于crossinline
关键词的更基本的问题.我真的不确定它解决了什么问题,以及它是如何解决的.
From the Kotlin Docs,
Note that some inline functions may call the lambdas passed to them as parameters not directly from the function body, but from another execution context, such as a local object or a nested function. In such cases, non-local control flow is also not allowed in the lambdas. To indicate that, the lambda parameter needs to be marked with the crossinline modifier:
[Emphasis added]
This statement is ambiguous to me. First, I am having trouble actually picturing what is meant by "such cases". I have a general idea of what the issue is but can't come up with a good example of it.
第二,短语"表明",可以有多种解读方式.表明什么?a particular case美元是不允许的?这是允许的吗?给定函数定义中的非局部控制流是(或不)允许的?
简而言之,我很难弄清楚使用这个关键词的真正背景是什么,使用它与客户沟通的内容是什么,以及应用这个关键词的预期结果是什么.