I´m developing a singleton class in Kotlin but I want check if the lateinit var "instance" is Initialized instead check if is null but It doesnt work. I think is better init the var like lateinit and no like null var.
companion object {
private lateinit var instance: GameDAO
fun getInstance(): GameDAO {
if (!::instance.isInitialized) {
synchronized(this) {
instance = GameDAO()
}
}
return instance
}
}
The compiler show me the next error: enter image description here