Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dvt32/d05580e6b7be10191e35dc7a64d1e86f to your computer and use it in GitHub Desktop.
Save dvt32/d05580e6b7be10191e35dc7a64d1e86f to your computer and use it in GitHub Desktop.
object ObjectDeclarationTest { // sort of like a Singleton
var i = 5L
fun doStuff() {
println("hello!")
}
}
fun test() { // no need to instantiate, everything is static
ObjectDeclarationTest.i = 10L
ObjectDeclarationTest.doStuff()
}
// We can also have functions WITHOUT a class ("top-level functions")
fun myFun() { println("Hello!") }
class BestClass {
fun someMethod() {
myFun()
test()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment