Skip to content

Instantly share code, notes, and snippets.

@arsalankhan994
Created February 12, 2022 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arsalankhan994/eef14c41592860c836ddd06fb33cfe4b to your computer and use it in GitHub Desktop.
Save arsalankhan994/eef14c41592860c836ddd06fb33cfe4b to your computer and use it in GitHub Desktop.
main() {
/*
object classes example
*/
val singleton = SingletonClass.age
println(singleton)
SingletonClass.updateAge(20)
println(SingletonClass.age)
}
/*
One create single instance of this class like Singleton Design Pattern
*/
object SingletonClass {
var age: Int = 27
fun updateAge(age: Int) {
this.age = age
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment