Pardip
07/13/2022, 1:46 PMabstract class A {
init {
foo()
}
abstract fun foo()
}
class B : A {
val b = /* init b */
override fun foo() {
b.something() // crash
}
}
The super class call foo()
on init so, the property b
is not yet initialisedribesg
07/13/2022, 2:22 PMfoo()
later one way or another, or implement foo()
through composition instead of inheritance, or somehow pass the information you're trying to convey with foo()
implementation through the super constructor, etc.ephemient
07/13/2022, 11:40 PMA
, something like "Calling non-final function foo in constructor"