How to add a method to a Scala Enumeration object?
问题 I'm using Scala 2.8 and defining an Enumeration like this: object Stooges extends Enumeration { type Stooge = Value val Larry, Curly, Moe = Value } And I want to add a method to this Enumeration that cycles to the "next" stooge. I can define such a method outside Stooges and this works in a test program just fine: def nextStooge(v:Stooges.Stooge):Stooges.Stooge = Stooges((v.id+1) % Stooges.values.size) What I'd really like is to add this method to Stooges and I have tried doing such a thing