Sorry if I’m posting this in the wrong category. Please let me know if there’s a better channel to report this.
https://kotlinlang.org/docs/reference/lambdas.html#lambda-expression-syntax
The full syntactic form of lambda expressions is as follows:
val sum: (Int, Int) -> Int = { x: Int, y: Int -> x + y }
…
If we leave all the optional annotations out, what’s left looks like this:val sum = { x, y -> x + y }
x
and y
must still have explicit types specified, right?
There’s another one that I found here
https://kotlinlang.org/docs/reference/this-expressions.html#qualified
Qualified
this
To access
this
from an outer scope (a class, or extension function, or labeled function literal with receiver) we writethis@label
where@label
is a label on the scopethis
is meant to be from:class A { // implicit label @A inner class B { // implicit label @B fun Int.foo() { // implicit label @foo val a = this@A // A's this val b = this@B // B's this val c = this // foo()'s receiver, an Int val c1 = this@foo // foo()'s receiver, an Int val funLit = lambda@ fun String.() { val d = this // funLit's receiver } val funLit2 = { s: String -> // foo()'s receiver, since enclosing lambda expression // doesn't have any receiver val d1 = this } } } }
This part
val funLit = lambda@ fun String.() {
val d = this // funLit's receiver
}
has to be changed to
val funLit = lambda@ fun String.() {
val d = this@lambda // funLit's receiver
}