KotlinSyntax
Object Singleton
Code example
object Config {
val version = 1
}Declares a single instance.
In Kotlin, object singleton: declares a single instance — object Config { val version = 1 }
object Config {
val version = 1
}object Config {
val version = 1
}Declares a single instance.
Use object Config { val version = 1 }.
Use this pattern: object Config { val version = 1 }
Yes. Use Copy code and adapt the example to your program.
No. The language syntax is the same across operating systems.