Where to Go From Here?
Download the final project using the Download Materials button at the top or bottom of this tutorial.
In this tutorial, you learned:
- What enums are and how to use them when you need a predefined set of constants
- How ART and R8 helped reduce the performance hit that used to be a problem with enums in the past
- How to use
when()
for flow control using enums
- Why exhaustive code matters and how enums help with this
- How to add extra data to enum constants
- How every enum in Kotlin implements equality automatically
- The use of
name
to pass enum cases via Intent
- How to add methods to enums
To learn even more about enums and their functionality, check out the Kotlin and Android: Beyond the Basics with Sealed Classes tutorial.
We hope you enjoyed this tutorial. If you have any questions or comments, please join the forum discussion below!