Safely accessing lateinit variables
Kotlin, by design, doesn’t allow a non-null variable to be left uninitialised during its declaration. To get past this issue, Kotlin’s lateinit allows us to declare a variable first and then initialise it some point in the future during our program’s execution cycle. The concept is simple, but when we try to access an uninitialised property, it’s…