合格它在kotlin

正如https://kotlinlang.org/docs/reference/this-expressions.html#qualified中的文档所述,可以使用合格的来指定要使用的外部上下文。 有没有什么办法it ? IntelliJ一直在说有一个sytax错误。

你已经知道了,但对于其他可能有相同问题的人,你可以这样做:

 foo.forEach { x -> x.forEach { y -> doSomething(x) + doSomething(y) } } 

好吧,不理我。 该文档在https://kotlinlang.org/docs/reference/lambdas.html#higher-order-functions上表示,如果您有{ it.something }块,那么相当于{ x -> x.something }