Created
August 14, 2022 15:24
-
-
Save dvt32/d05580e6b7be10191e35dc7a64d1e86f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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