Selection Statements

The selection statement is based on the if/else constructs.

Syntax: if ( cond_expr ) statement1 [else statement2]
where cond_expr is a boolean expression, and statement1 and statement2 may be any statement: an expression statement, an iteration statement, a compound statement, a selection statement, a function definition statement, a jump statement or an empty statement.

Semantics: if the boolean expression cond_expr is evaluated to true, the statement statement1 is executed. Otherwise, if an else part is there, the statement statement2 is executed. The statements 1 and 2 may be any statement: an expression statement, iteration statement, compound statement, selection statement, function definition statement, jump statement or empty statement.
Note that a selection statement does not return any atom

The following table presents several examples of if/else statements:
if/else Statement Examples
if (true) a := 1;
the variable a is assigned to 1
if (1) b := 2;
an error is raised: boolean expected for condition
if (check(10) > 54) {a := 1; b := 2;} else {c := 2; d := 2}
here compound statements are used, because several expression statements need to be executed
if ((check(10) > 54 || alpha < 2) && beta > 2.3 ) {callme(2);}
use of a composite conditional expression
if (a == 1) b := 2; else if (b == 3) {c := 2; return 4;} else if (check(1)) return 2; else return 3;
selection statements are combined

EyeDB manual