Initialization of delegated properties
Hello,
I’m using delegated properties like
class Example {
val defaultInstance: ItemClass
get() {
return items.firstOrNull() ?: ItemClass().also { items.add(it) }
}
override var propA: String by defaultInstance::propB
}
In short words: I’m going to delegate some properties to the first item in a list of items.If no item exists I create an initial item.
The given code is not working, since the property propA is “initialized” in the constructor. I’m wodering, since the propA does not have any...