So I have a some Scala Enumeration object:
object KnotType extends Enumeration {
type KnotType = Value
val STOPPER, HITCH, ENDLOOP, MIDLOOP, ADJUSTABLELOOP, BEND, BINDING = Value
}
import KnotType._
object AnotherType extends Enumeration {
... }
import AnotherType ._
I want to initialize a new ValueSet instance with one Value present only. In the shortest of shorthands:
val eKnots = STOPPER + HITCH
eKnot: KnotType.ValueSet = KnotType.ValueSet(STOPPER , HITCH)
Works a charm. However, to create a ValueSet from one value I have to be more explicit: (especially as there are more than on enum object classes)
Creating a enumeration from one value produces a Value (as expected) but is not what I'm after (a ValueSet):
val eKnot = STOPPER
eKnot: KnotType.Value = STOPPER
A conventional way would be:
val eKnot = KnotType.ValueSet(STOPPER)
eKnot: KnotType.ValueSet = KnotType.ValueSet(STOPPER)
an inelegant way:
val eKnot = STOPPER + STOPPER
eKnot: KnotType.ValueSet = KnotType.ValueSet(STOPPER)
a long winded way - works fine but I'm after succinctness
val eKnot = KnotType.ValueSet.empty + STOPPER
eKnot: KnotType.ValueSet = KnotType.ValueSet(STOPPER)
Is there any other shorthand I could use? i.e val eKnot = STOPPER + /somethingsimple/