Image credit Jesus Kiteque on Unsplash

When writing code, we can usually avoid using null . It represents a state.

In Kotlin, there are many ways to avoid using null. In this article, we will show how to avoid using null to represent the empty state.

For example, the typical Java definition of a linked list is

Typical Java implementation of a linked list node