最佳答案
I have to say I don't understand Scala enumeration classes. I can copy-paste the example from documentation, but I have no idea what is going on.
object WeekDay extends Enumeration {
type WeekDay = Value
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
}
import WeekDay._
type WeekDay = Value
and why do I have to write that? val Mon = Value
? What does that even mean?WeekDay
object? And,val day = WeekDay.Mon
, why is it type WeekDay.Value
, not type WeekDay
?