Introduction to the Nothing Type

Explore the pivotal role of the Nothing type in handling exceptions, non-terminating scenarios, and type hierarchy, including its interactions with null values.

The Nothing type is a subtype of all the types in Kotlin. If we had an instance of this type, it could be used instead of everything else (like a Joker in the card game Rummy). It’s no wonder that such an instance does not exist. The Nothing type is an empty type (also known as a bottom type, zero type, uninhabited type, or never type), which means it has no values.

It is literally impossible to make an instance of the Nothing type, but this type is still really useful. Some functions declare Nothing as their result type. We’ve likely used such functions many times already.

Get hands-on with 1200+ tech skills courses.