0

I am trying to evaluate if my two variables each match one of multiple values in an if statement. I'm trying:

if ( ( variable1 == A || B ) && ( variable2 == C || D ) )

Error: use of logical '||' with constant operand.

I managed to fix it (below) but this seems tedious and repetitive and I am wondering if there is a simpler fix.

if ( ( variable1 == A || variable1 == B ) && ( variable2 == C || variable2 == D ) )

Thanks!

1 Answer 1

0

If we're not assuming anything about the values A, B, C, and D, I don't think it gets any simpler than this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .