Common programming bug in decision statement!

Suppose you have a variable called Feedback and you want to find out if the value is 1 or 2.  Does the following work?

Feedback = 1 OR 2

No, it first evaluates the righthand side of the expression “1 OR 2” as True.  Actually 1 is True so “1 OR anything” will be true.  I know that’s not what you wanted.  What you wanted was

(Feedback =1) OR (Feedback = 2)

which produces the correct, expected result.  Caveat emptor

Leave a Reply

Your email address will not be published.