https://kotlinlang.org logo
Title
r

Ruckus

05/11/2018, 8:10 PM
package demo

val name = "package"

fun main(args: Array<String>) {
    val name = "local"

    class Test {
        val name = "class"
        val a get() = name  // returns "local"
        val b get() = this.name  // returns "class"
        val c get() = demo.name  // returns "package"
    }
}
m

marcinmoskala

05/11/2018, 8:13 PM
Looks a bit counterintuitive, but now I see why it might be by design - no other way to reference local variables once they are hidden. You sure that this is "by design"?
r

Ruckus

05/11/2018, 8:13 PM
I am
m

marcinmoskala

05/11/2018, 8:13 PM
👍
r

Ruckus

05/11/2018, 8:14 PM
See my comment later in the channel