Learn what an enum is and how to use it.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4736-programming-in-kotlin/lessons/62
Learn what an enum is and how to use it.
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: https://kotlinlang.org/docs/reference/enum-classes.html
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