Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving name attribute from Scala Enumeration Value

Tags:

scala

I have created a Scala Enumeration as follows:

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

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

How is it possible to retieve the "Pause Timer" or "Resume Timer" text from my enumeration Values?

I can retrieve the id using myMatch.timerStatus.id but I don't see any way to get the name

If not possible, what is best workaround?

like image 693
DJ180 Avatar asked Apr 01 '13 01:04

DJ180


1 Answers

.toString method returns the name.

like image 149
Alex Yarmula Avatar answered Sep 28 '22 01:09

Alex Yarmula