From the stream
Given we have an enum
enum Foo
{
ABC,
DEF,
GGG,
HHH
}
If we need to write this combination of cases in many places at once in the code, eg a compiler or any other state machine
switch(f)
{
case ABC:
case GGG:
io::printn("handle case");
case DEF:
case HHH:
io::print("handle case2");
}
This could be written, helpful if you're writing this in many places throughout your code, also can be a bit more self documenting
const Foo[2] EXPR = {ABC, GGG};
const Foo[2] LITERAL = {DEF, HHH};
switch(f)
{
case EXPR:
io::printn("handle case");
case LITERAL:
io::printn("handle case");
}
I think that also allows this by extension, but not sure
switch(f)
{
case {ABC, GGG}:
io::printn("handle case");
case {DEF, HHH}:
io::printn("handle case");
}
From the stream
Given we have an enum
If we need to write this combination of cases in many places at once in the code, eg a compiler or any other state machine
This could be written, helpful if you're writing this in many places throughout your code, also can be a bit more self documenting
I think that also allows this by extension, but not sure