I'm wondering if you can extend already existing enumerations in Scala. For example:
object BasicAnimal extends Enumeration{
type BasicAnimal = Value
val Cat, Dog = Value
}
Can this be extended something like this:
object FourLeggedAnimal extends BasicAnimal{
type FourLeggedAnimal = Value
val Dragon = Value
}
Then, the elements in FourLeggedAnimal would be Cat, Dog and Dragon. Can this be done?
No, you cannot do this. The identifier BasicAnimal
after extends
is not a type, it is a value, so it won't work, unfortunately.