Boolean Conditions

Sometimes you will want your program to check a more complicated state than can be represented with a single condition. Conditions can be combined with the boolean operators and, or and not. The syntax for these is shown below:
Boolean Operation Syntax
and
&&
or
||
not
!

Boolean operators can be used to combine conditions. For instance:

condition1 && condition2   	will be true if both conditions are true
condition1 || condition2   	will be true if either condition is true
!condition1			will be true if condition1 is false

Brackets can be used to create more complex conditions. For example:

!(condition1 || condition2)   will be true only if both condition1 and condition2 are false

next


 home                      table of contents                      about