I would like to call some code inside my class init block, after a property y is initialized. I've tried it with this::y.isInitialized
..., but the problem here is that at the creation of the class, the property is not initialized (which it gets during runtime).
ExampleClass
class Example {
lateinit var y: String // this gets initialized after the creation of the fragment at a later time
init {
if(this::y.isInitialized) {
doStuff()
}
}
}
Szenario
val testObject = Example()
testObject.y = "START INIT CODE" // here it should execute the init block
Is this even possible? Or should I change the init block with a function call after I ensure that y
is initialized?