[Issue 1112] New: Allow enums in WithStatements
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 8 09:51:37 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1112
Summary: Allow enums in WithStatements
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: deewiant at gmail.com
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;
}
}
--
More information about the Digitalmars-d-bugs
mailing list