AutoClear init fix

This commit is contained in:
shabinder 2021-07-10 13:06:25 +05:30
parent 43ca70daf7
commit 79ad318264

View File

@ -28,7 +28,8 @@ class AutoClear<T : Any?>(
get() = observer.value get() = observer.value
set(value) { observer.value = value } set(value) { observer.value = value }
val value: T get() = _value.requireNotNull() val value: T get() = _value ?: initializer?.invoke()
?: throw IllegalStateException("The value has not yet been set or no default initializer provided")
fun getOrNull(): T? = _value fun getOrNull(): T? = _value