July 2018
Intermediate to advanced
400 pages
12h 14m
English
All of the functions that you have written so far have been defined at the file level in Game.kt. If you are a Java developer, then this may seem surprising to you. In Java, functions and variables can only be defined within classes, a rule that Kotlin does not adhere to.
How is this possible if Kotlin code compiles to Java bytecode to run on the JVM? Does Kotlin not have to play by the same rules? A look at the decompiled Java bytecode for Game.kt should prove illuminating:
public final class GameKt {
public static final void main(...) {
...
}
private static final String formatHealthStatus(...) {
...
}
private static final void printPlayerStatus(...) {
...
}
private static final ...Read now
Unlock full access