<SPAN CLASS="TOKEN" >if</SPAN > statements

Sather - Language Specification
Prev | Chapter 5. Basic Statements | Next

# 5.3. if statements

Example 5-3. Example:

    if a>5 then foo
    elsif a>2 then bar
    else error
    end

    if_statement ==>
            if expression then  statement_list { elsif expression  then  statement_list } [ else statement_list ] end

if statements are used to conditionally execute statement lists according to the value of a boolean expression. Each expression in the form must return a boolean value. The first expression is evaluated and if it is true, the following statement list is executed. If it is false, then the expressions of successive elsif clauses are evaluated in order. The statement list following the first of these to return true is executed. If none of the expressions return true and there is an else clause, then its statement list is executed.

Prev | Home | Next
Assignment statements | Up | return statements