The Problem: Keywords
In Java, when
is not a keyword.
In Kotlin, when
is a keyword. And, like many programming languages, keywords are reserved symbols. You cannot use those symbols for your own function names, properties, and the like.
Every now and then, you will encounter a Java library, like Mockito, that uses Kotlin keywords for method names. Since the library is already compiled, the library itself is fine. And if the collision on the Kotlin keyword is purely part of the internal implementation of the library, everything is fine. But, if the collision is in the public API of the library, developers using Kotlin would be unable to call that API.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.