Expressions and Conditions

With variables and statements, you can store as much data as you like, but eventually you'll want to manipulate it or check it. Expressions and Conditions are used for these two tasks. Expressions combine values into a new value whereas conditions compare values and return a Boolean truth value (true or false). Conditions are a kind of expression most often concerned with testing logical (truth or boolean) values.

Expressions and conditions combine variables and constant data (and other expressions and conditions) together via operators. Except for string manipulation, the operators are mostly identical to those of the "C" and Java languages. An important matter is precedence, which is a set of rules dictating how expressions are interpreted when more then one operator is present. Parentheses, '()' can be used to force a different interpretation to that laid down in the precedence rules. The Reference Section lists all the operators and their precedence.

An operator has to work with something in order to operate. Operators are divided into unary operators that operate on one piece of data and binary operators that operate on two pieces of data, one on each side of the operator symbol. There is also a single ternary operator that uses three pieces of data.

© 1997 by Wrox Press. All rights reserved.