Singleton
01
Singleton Objects
The 'object' keyword in Jackal defines a unique, globally accessible instance. It allows for immediate property assignment and method execution without manual instantiation.
spec_manifest.jk
object Person(name) {
func getName() {
return this.name
}
}
Person.name = "jack"
println(Person.getName())
02
Global Configuration
Singletons provide a structured way to maintain global state. Properties assigned to the object are persistent across the application lifecycle.
spec_manifest.jk
object Config(version, env) {
func getDetails() {
println("Version:", this.version, "Env:", this.env)
}
}
Config.version = 1.0
Config.env = "production"
Config.getDetails()
← Return to Index
Technical Documentation