Effective Kotlin: Item 3 — Enforce the singleton property with a private constructor or an enum type

There are a few different ways of enforcing the Singleton pattern in Java as suggested by Effective Java. Joshua Bloch goes into details of the pros and cons of each, so I recommend you take a look at his book.

Naively you could create a singleton by copying the Java pattern verbatim. However, Kotlin provides the Object declaration that makes it easy to declare. An object can extend other classes and interfaces.

object Singleton {…