views:

71

answers:

1

This code does not compile:

object Token extends Enumeration {
    type ID = Value
    val Key, Value = Value
}

error: recursive value Value needs type

What should be done to have 'Value' in the enumeration ?

+3  A: 

This is not possible because Value is already a final member of Enumeration - the obvious suggestion is to call your field Val instead.

oxbow_lakes
Very sad. I wanted to rely on the content of the toString() method of the enumeration. I wanted it to coincide with the class name on the companion class. I have to look for another solution.