Comment #0 by matti.niemenmaa+dbugzilla — 2007-04-08T11:51:36Z
Been asked for a few times, submitting it here for posterity.
enum Enum {
A = 0, B, C
}
void main() {
with (Enum) {
assert (A == 0);
assert (B == A+1);
assert (C == B+1);
}
}
It would be handy if the above worked. A common use case is switching on an enum:
enum Enum {
A = 0, B, C
}
void main() {
Enum e;
with (Enum) switch (e) {
case A:
case B:
case C:
default: break;
}
// the above looks much better than:
switch (e) {
case Enum.A:
case Enum.B:
case Enum.C:
default: break;
}
}