how to create singleton in kotlin code example
Example 1: kotlin singleton
// Just use object
object SomeSingleton
Example 2: Kotlin singleton
object MySingleton {
fun myMethod(): Int {
return 5
}
}
MySingleton.myMethod() // 5
// Just use object
object SomeSingleton
object MySingleton {
fun myMethod(): Int {
return 5
}
}
MySingleton.myMethod() // 5