Here's a little summary of how logical boolean operators work:
The operators:
Code:
a == b //returns true if 'a' is equal to 'b'. this is NOT THE SAME AS 'a = b'
a && b //returns true if both 'a' and 'b' are true, returns false in all other cases
a || b // returns true if 'a' is true, if 'b' is true', or if both 'a' and 'b' or true. Only returns false if both 'a' and 'b' are false.
you can replace 'a' and 'b' with any expressions which evaluate to a boolean value. These all associate left to right and are on the same level of operator precedence.
The expression "a && b || c" is evaluated like this "(a && b) || c".
Here's an example of how you might use boolean operators in a program:
Code:
if ( (a == 3) || (a ==5) ) //execute "do stuff" if a == 3 is true, a ==5 is true, or they both are true.
//do stuff
else //execute "do other stuff" if a != 3 AND a != 5
//do other stuff
the above code is the same as
Code:
if ( (a == 3) || (a ==5) )
//do stuff
if ( (a != 3) && (a != 5) )
//do other stuff
hope that helped.