Robert
10/29/2020, 8:35 PMRyan
10/29/2020, 8:38 PMRobert
10/29/2020, 8:42 PMRyan
10/29/2020, 8:42 PMephemient
10/29/2020, 8:42 PMRobert
10/29/2020, 8:43 PMRyan
10/29/2020, 8:44 PMRobert
10/29/2020, 8:47 PMsomeVarName = "other value"
print(someVarName) // should output "other value", not "some value"
Ryan
10/29/2020, 8:47 PMRobert
10/29/2020, 8:47 PMvar someVarName by lazy {
"some value"
}
Just like this?ephemient
10/29/2020, 8:48 PMRyan
10/29/2020, 8:48 PMRobert
10/29/2020, 8:49 PMephemient
10/29/2020, 8:49 PMprivate var _isEmpty: Boolean? = null
var isEmpty: Boolean
get() = _isEmpty ?: throw UninitializedPropertyAccessException("property isEmpty has not been initialized")
set(value) {
_isEmpty = value
}
Ryan
10/29/2020, 8:50 PMephemient
10/29/2020, 8:50 PMRobert
10/29/2020, 8:50 PMRyan
10/29/2020, 8:50 PMephemient
10/29/2020, 8:51 PMDelegates.notNull()
may suit your purposesimport kotlin.properties.Delegates
var someVarName: String by Delegates.notNull()
someVarName = "some value"
Robert
10/29/2020, 9:24 PMephemient
10/29/2020, 9:30 PM