Understanding the Rules of Precedence

PracticeScript uses the following order of precedence:

Using the rules of precedence, the following complex expression:

3 + 4 * 5 = 35 OR 3 + 4 * 5 <= 23 AND 4 < 10

should be interpreted as:

3 + 20 = 35 OR 3 + 20 <= 23 AND 4 < 10

Multiplication has the highest precedence, followed by addition.

The comparison operators, FALSE OR TRUE AND TRUE, are next.

Logical AND is next, followed by logical OR.

Using Parentheses

In the list of operator precedence, an explicit grouping using parentheses has the highest precedence. Even when they are not necessary, parentheses can make an expression clearer.

For example, the expression 3 + (4 * 5) is easier to read with the parentheses, even though they are not necessary.

Be sure to use parentheses with the logical operators AND and OR, because they are not on the same level.

Example:  

 

 

Related Topics

Using PracticeScript

Understanding the Language

Understanding Character Expressions