BeginnerOOP
object Singleton
A singleton utility with object.
kotlin
object AppConfig {
const val VERSION = "1.0"
fun banner() = "KotlinGuide v$VERSION"
}
fun main() {
println(AppConfig.banner())
}Output
KotlinGuide v1.0
Explanation
object creates one shared instance. Access members directly via AppConfig.