Refer to enums by short name?

Any plans/desire to have enum syntax sort of like Swift, where you don't need to fully qualify the name if the type is known?

  enum class Color { Red, Blue }


  fun paint(c: Color) { }


  paint(.Red)   // for example

Rob

Hi Rob,

You can use a wildcard import. e.g. import foo.Color.*

Note: this doesn’t seem to be possible in the same file that defines the enum, but works elsewhere.

Cheers,
Andrew

Hi Rob,

It’s planned (but not implemented yet) to have short syntax inside when, as in Java, e.g.

  fun paint(c: Color) = when (c) {
  RED -> …

  GREEN -> …
  }

Also you can use wildcard import, as Andrew has written.

Okay, thanks guys.

Rob