How do I check if user
variable is initialized when an instance of MyClass
is created?
class MyClass
{
companion object
{
lateinit var user:User
}
init
{
//initialize if not initialized
//user.isInitialized
user = User
}
}
What I want to do is initialize the variable only when the 1st instance of MyClass is created, and the same value of this variable should be accessible across all instances.If it's not possible to use isInitialzed like this, then a workaround is acceptable as well.