Explicit "do nothing" construct?

Adding any keyword to the language is not easy at all, because it will break all code that has used that word as an identifier. Given the backwards compatibility promises given at the release of Kotlin 1.0, this needs very strong arguments.

As you correctly write, Kotlin has two existing possibilities to express the same idea with the same amount of characters. Learning the meaning of Unit or an empty pair of braces in this context is not much harder than learning a new keyword. Therefore, the argument doesn’t seem strong.

Not to mention the fact that you can define it yourself if you think that it will make your code more readable: val pass: Unit = Unit

11 Likes