PreviousNext
Help > PROGRAM CONTROL STRUCTURES > Conditional Branch
Conditional Branch

Conditional statements use the traditional structure in many programming languages “if” … “else” … “endif”.

In Rittle this structure is expanded by allowing multiple “else” statements with their own conditional expressions.

The full format is (unlimited number of “else” statements is allowed):

if condition1;

    ……. here if condition1 is true …….

else condition2;

    ……. here if condition2 is true …….

else condition3;

    ……. here if condition3 is true …….

 

…………

else conditionX;

    ……. here if conditionX is true …….

else;

    ……. here otherwise …….

endif;

 

Note the semi-colon ‘;’ characters completing every statement. Without a semi-colon in the proper place, a statement may come to a completely different meaning during execution or generate an error during compilation.

All “else” branches are optional. The opening “if” and the closing “endif” however must be present in every structure.

The final “else” may have no condition but still has the statement closing semi-colon. It catches all cases uncovered by any other branch in the structure.