singleton pattern method best way in kotlin
Can someone help me to find a better way to create a singleton pattern in Kotlin?
private lateinit var foo: FooService
override fun getService(): FooService {
if (!::foo.isInitialized) {
foo = FooService(...)
}
return foo
}
Thanks in advance!