You may not need a sealed class

When it comes to decide between using an enum or a sealed class in Kotlin, I’ve seen several situations where developers where using them indistinctly.

Generally speaking, sealed classes are more powerful than enums. This is because a sealed class is just an abstract class which requires to define every child class in the same Kotlin source file.

Enum vs sealed class



Impure developer and functional programming enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

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