Scala enumeration to int

Viewed 7883

Is there a way to identify that a given object is an Enumeration value?

x.isInstanceOf[Enumeration.$Value] doesn't seem to work, and from what I understand of path-dependent types, shouldn't.

I'd like to write a function that given any Enumeration value, returns its id. Alternatively, an implicit that converts the Enumeration to Int would also be great.

2 Answers
Related