https://kotlinlang.org logo
#kontributors
Title
# kontributors
e

Egor Trutenko

05/09/2018, 4:17 AM
Is it actually a good practice to use Singleton pattern in Kotlin? If yes, will there be more convenient methods of creating Singletons? Because
Copy code
private object Holder { val INSTANCE }
companion object { instance: ClassName by lazy { Holder.INSTANCE } }
Is kinda irritating to write and read.
g

gildor

05/15/2018, 9:47 AM
Why not just
object MySingleton
? It’s standard Kotlin way to create thread safe singletons with syntactic sugar accessors
Also not sure that this somehow related to this channel
4 Views