Kotlin Enum Classes

Enums are special classes which limit the possible values of an object for that class. The possible values defined for that class are final or unchangeable.

The easiest way to define an enum is

Here each enum constant is an object.

For using these values

Base class of all Enum Classes

There is a base class for all enum classes which is defined in kotlin package.

Name and Ordinal

These two properties are available by default for each enum constant as these are added in the base class itself.

Name is the actual name by which the enum constant is defined whereas ordinal is the sequence of that particular enum constant in the enum class having the first one starting from 0

Please continue reading at https://agrawalsuneet.github.io/blogs/kotlin-enum-classes/

That’s all for now. You can read my other interesting posts here or you can enjoy my games or apps listed here. Feel free to use my open-source Android components in your app listed here. Or drop an email, if you didn’t find what you are looking for and need some help.

--

--

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