Reputation: 266950
I have an enumeration like this:
object UserType extends Enumeration {
type UserType = String
val member = "member"
val admin = "admin"
}
Is there a way to get all the values of the Enumeration so it returns:
val userTypes: Set[String] = UserType.values.toSet
For some reason UserType.values
returns of type UserType.Value or something, not a string.
Is there a way to accomplish this?
Upvotes: 0
Views: 127
Reputation: 2545
If you want use Enumeration need set Value
to your type:
type UserType = Value
And then define variable as:
val admin = Value("admin")
Otherwise, you don't use a Enumeration.
For get list of all values:
UserType.values.toList
Upvotes: 2