If I have a lateinit variable, I could check is it initialized using (this::lateInitVar.isInitialized), as shown in https://stackoverflow.com/a/47860466/3286489
Howe
You could extract it into a function inside the companion object:
class MyClass {
companion object {
lateinit var myGlobalLateInit: String
fun isMyGlobalLateInitInitialized() = ::myGlobalLateInit.isInitialized
}
fun settingVariable() {
if (!isMyGlobalLateInitInitialized()) {
myGlobalLateInit = "I am set"
}
}
}