Enum initialization


Current enum initialization requires the class name:

enum class Color(val rgb : Int) {
  RED : Color(0xFF0000)
  GREEN : Color(0x00FF00)
  BLUE : Color(0x0000FF)

Is there a reason that it isn’t implemented to support initialization without the class name? For a large number of enum values the class name is repetitve and seems to create a lot of noise. Why not as follows?

enum class Color(val rgb : Int) {


There are a few technical reasons for this. We are working on them.

It’s mostly syntactic ambiguity and overal logical structure of the language