July 2018
Intermediate to advanced
242 pages
8h 6m
English
Thanks to providing the alternative function names, we were able to compile them to JVM bytecode. However, you can easily test that we can use their original names inside the Kotlin code. That's because the Kotlin compiler is able to recognize them correctly based on their return type and generic type argument value.
You can test this by running the join() function both on the list of integers and on the list of strings:
fun main(vararg args: String) { println(listOf(1, 2, 3).join()) println(listOf("a", "b", "c").join())}
As the result, the preceding code will print the following text to the console:
1, 2, 3a, b, c
Keep in mind that, when you want to invoke those functions from Java, you will need to use their alternative ...
Read now
Unlock full access