Scala 3 Enum - Manually define associated integers

69 Views Asked by At

As of Scala 3.3.1 is there any way to set custom integer values for each case?

If I try with:

enum MyEnum:
  case E1
    override def ordinal: Int = 1

I get a this error:

the ordinal method of enum class MyEnum can not be defined by the user

0

There are 0 best solutions below