DPL 9 Help

Conditional Operator

Conditional Operator

The conditional operator (? :) takes the form:

operand1 ? operand2 : operand3

The conditional operator is the only one in DPL with three operands. It tests operand1 to see whether it is 0. The conditional operator interprets operand1 as being true if it is not 0 and false if it is 0. If operand1 is not 0 (true), the operator evaluates and returns operand2. If operand1 is 0 (false), the conditional operator evaluates and returns operand3. The conditional operator is similar to the if( ) spreadsheet function.

Examples of the conditional operator are:

x != 0 ? y/x : 0
x ? y/x : 0

The expressions are equivalent, although the first one is easier to interpret. When x does not equal 0, the expressions equal y/x. Otherwise they equal 0.

Versions: DPL Professional, DPL Enterprise, DPL Portfolio

See Also

Operators