Nullability

As we said, some elements in Kotlin can be assigned a value of null, and some cannot. We say that the former are nullable and the latter are non-nullable.

Null is not the same as zero or a statement of no value. Think about your bounty board. In the context of a fantasy game, the bounty board likely manifests as a literal bulletin board with quests on it. There is a difference between the board not having a quest (in other words, having a null value) and having a message that says There are no quests right now.

While null and “There are no quests right now.” might be interpreted in the same way, they have different implications. A value of null signifies that nothing is present: There are no quests, there is no message ...

Get Kotlin Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.