We all know that C has expressions if, and parts of this family are operators else ifand else. elseBy itself, it checks to see if any of the values succeeded, and if so, it runs the processing code.
I was wondering if there is something like the opposite elsethat checks if all values have succeeded, and not one of them.
Let's say I have this code:
if (someBool)
{
someBit &= 3;
someFunction();
}
else if (someOtherBool)
{
someBit |= 3;
someFunction();
}
else if (anotherBool)
{
someBit ^= 3;
someFunction();
}
else
{
someOtherFunction();
}
Of course, I could shorten this with:
- a
goto(yes, I wonder why I won’t do it) - record
if (someBool || someOtherBool || anotherBool)(dirty and not remote portability).
I realized that it would be much easier to write something like this:
if (someBool)
someBit &= 3;
else if (someOtherBool)
someBit |= 3;
else if (anotherBool)
someBit ^= 3;
all // if all values succeed, run someFunction
someFunction();
else
someOtherFunction();
Does C have this feature?