How can I define an enum with specific numeric values in Scala and be able to get the value list from the type?
If I define the enum using the Enumeration
type as follows:
object MyEnum extends Enumeration {
type MyEnum = Value
val A: Byte = -10
val B: Byte = 0
val C: Byte = 10
}
and try to get the values as follows:
val byteValues = MyEnum.values.toList.map(_.id.toByte)
then I get an empty sequence.