S
Simon Cooke
I have many OR in the if statement, any method to simplify?
if (val == 5 | val == 9 | val == 34 | val == 111 | val == 131 | .......)
// ....
thank you
Could you give a more specific example of what you're trying to do with
your test?
If you're trying to sieve out these different values, it's a different case
than if you're trying to run special case code for some other reason.
For example, depending on what you're doing, it might make more sense to do
this:
bool hit = false;
if (val == 5) {
do something
hit = true;
}
else if (val == 32 || val = 64) {
do something else
hit = true;
}
if (hit) { do something if any of them were matched }