Programming in Kotlin - Part 62: Enums | Ray Wenderlich

Learn what an enum is and how to use it.

This is a companion discussion topic for the original entry at

Hey you sure you don’t want to put “val” in the constructor of Color for g and b as well. bit misleading.

enum class Color(val r: Int, val g: Int, val b: Int) …

So that G and B are also properties.

I figured you are taking your examples from:

and makes sense why you might have made this typo:

enum class Color(val rgb: Int)

My humble opinion, it would have been nicer through out the course to have at least more original examples, given most examples in the subjects seems to be almost the same as the reference docs (unless of course that was intentional)

Thanks for finding that. It should have the val’s before g & b.

Also, thanks for the feedback. I’ll put in better examples next time