October 2019
Intermediate to advanced
434 pages
11h 54m
English
To understand how to control generated class naming, we'll explore how these class names are generated by the Kotlin compiler by default. In this snippet, we've defined a new top-level function named sayHello():
// GreetingFunctions.ktfun sayHello(name: String) = println("Hello $name!")
This function prints a simple greeting and can be used freely from the rest of our Kotlin code, like this:
// Main.ktfun main() { sayHello("Nate")}
In this Kotlin case, calling the top-level function feels like a natural part of the language because the function is freely available, and is not associated with any class. However, from Java's perspective, that's not the case. To invoke the sayHello() function from Java, we must ...
Read now
Unlock full access