I have an enum like this:
object Ops extends Enumeration {
val one = Value(0x01)
val two = Value(0x02)
val three = Value(0x03)
val four = Value(0x04)
}
I want to say
Byte someByte = functionThatReturnsAByte
val op = Ops.valueOf(someByte)
The only method close is withName which only takes a String.
Ops(someByte)
will do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With