Hi can I have the same variable name in a class an...
# kotlin-native
r
Hi can I have the same variable name in a class and its sub-inner class, and be able to call it in that inner class?
Copy code
class A {
   var x = 5
   
   inner class B {
       val x = "upper-class".x 
   }
}
1
👌 1
b
Copy code
class test {
    val x = 3
    inner class test2 {
        val test = x
    }
}
r
well, yes i know this is possible but I was wondering if I can use the same name of the variable
r
This works for me:
Copy code
class A {
  var x = 5

  inner class B {
    val x = this@A.x
  }
}