kotlin 如何在多层应用函数中引用外部范围 this [英] kotlin how to refer outer-scope this in multi-layer apply functions
本文介绍了kotlin 如何在多层应用函数中引用外部范围 this的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
v1?.apply {
v2?.apply {
call(this, target, outerThis);
}
}
我的问题是如何引用outerThis"?感谢您的帮助.
my question is how to refer to "outerThis"? thanks for any help.
推荐答案
您可以使用 标签 然后是 合格的 this代码>
表达式:
You can use a label and then a qualified this
expression:
v1?.apply outer@ {
v2?.apply {
call(this, target, this@outer)
}
}
这篇关于kotlin 如何在多层应用函数中引用外部范围 this的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文