Retrieving a Name Attribute from Scala Listing Value

I created the Scala enumeration as follows:

object TimerStatus extends Enumeration {
    type Status = Value
    val InProgress = Value(1, "Pause Timer")
    val Paused = Value(-1, "Resume Timer")  
}

Then I have a Match class that contains TimerStatus as a member

How can I return the text “Pause timer” or “Resume timer” from my enumeration values?

I can get the id using myMatch.timerStatus.id, but I see no way to getname

If this is not possible, what is the best way to do this?

+5
source share
1 answer

.toString method returns name.

+16
source

All Articles