enums - Change scala Enumeration id -
i want create enum type value can changed. consider following:
object type extends enumeration { var = value(0, "some string1") val b = value(1, "some string2") val c = value(2, "some string3") } i gave every enum field value want have option change value. , reading values table enum same value option. possible ?
in common parlance, enum not mutable. elements enumerated @ compile time, typesafe constants.
also, enumeration relatively fragile.
scala> object x extends enumeration { var x = value(0, "a") ; def f() = x = value(1, "b") } defined object x scala> x.x res1: x.value = scala> x.f() scala> x.x res3: x.value = b scala> x.values res4: x.valueset = x.valueset(a, b)
Comments
Post a Comment