Luis Munoz
08/28/2019, 3:22 PMBurkhard
08/28/2019, 3:41 PMprivate var backingField: Foo? = null
set(value) {
if(field == null) field = value
else throw IllegalStateException("field already initialized")
}
val property: Foo
get() = backingField ?: throw IllegalStateException("field not initialized")
Burkhard
08/28/2019, 3:42 PMAny?
and create a dummy singleton object that represents the absence of a value. In the normal property just add a cast to the right type.Burkhard
08/28/2019, 3:43 PMLuis Munoz
08/28/2019, 4:06 PMDico
08/28/2019, 4:34 PMcheck(field == null)
and checkNotNull(backingField)