It is a matter of simple pragmatism. A case like Just a | Nothing is extremely common in the actual application code. So common, in fact, that it totally warrants a separate syntactic support by the programming language and Kotlin’s nullable types deliver it. It makes most typical day-to-day application code easier to read, easier to write, with less boilerplate and more focus on the substance.

Definitely, there would be cases where you need more details and more alternatives. Kotlin has sealed types for that. They are more verbose and that is so by design. They occur much less often in practice.

Written by

Project Lead for the Kotlin Programming Language @JetBrains

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store