Kotlin: lateinit to val, or, alternatively, a var that can set once
You can implement own delegate like this: class InitOnceProperty<T> : ReadWriteProperty<Any, T> { private object EMPTY private var value: Any? = EMPTY override fun getValue(thisRef: Any, property: KProperty<*>): T { if (value == EMPTY) { throw IllegalStateException(“Value isn’t initialized”) } else { return value as T } } override fun setValue(thisRef: Any, property: KProperty<*>, value: … Read more