Conditional Statement ?:

Syntax

$ Expression1 "?" Expression2 ":" Expression3

Description

The ?: conditional statement returns one of the two values depending on the value of the Expression1 logical expression.

If the Expression1 expression returns True, the Expression2 expression is calculated and regarded as the result. If the Expression1 expression returns False, the Expression3 expression is calculated and regarded as the result. In all cases only one expression is calculated.

Example

Sub Main;

Var

i, j: Double;

Begin

i := Math.Rand;

j := Math.Rand;

Debug.WriteLine(i > j ? "i>j" : "i<j");

End Sub Main;

When the example is executed, two random numbers are generated. The result of comparison of the number is displayed in the development environment console.

See also:

Statements