首页 > 解决方案 > 如何从嵌套 lambda 引用单个参数(它)的上层 lambda 隐式名称?

问题描述

例如,我有一段代码:

                testie.testy?.let { // reference to this it
                    testContext.update {
                        it.testiest = it //How can I there reference to upper-level it?
                    }
                }

如何在块中引用 from it.tesiestto ?itlet

对于现在的解决方法,我在上面的 lambda 中使用命名参数。但我认为在不引入命名变量的情况下,还有其他方法可以在正确的位置进行引用。

标签: kotlinlambda

解决方案


推荐阅读