CLOVIS
09/19/2022, 12:02 PMabstract class A {
abstract inner class B : A() {
init {
// How can I access the outer class?
}
}
}
In that example, this refers to the class B, this@A refers to the parent class. How can I access the outer class?Marcus Brito
09/19/2022, 12:04 PMval in the proper scope:
abstract class A {
val a = this;
abstract inner class B : A() {
init {
// use `a` here
}
}
}CLOVIS
09/19/2022, 12:07 PMCLOVIS
09/19/2022, 12:10 PMCLOVIS
09/19/2022, 12:21 PMVampire
09/19/2022, 12:29 PMprivate val, then it works. Because you cannot access it from subclass, but within that scope.CLOVIS
09/19/2022, 12:32 PMVampire
09/19/2022, 2:46 PMVampire
09/19/2022, 3:54 PM