[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.2.9.1 The if/else statement

The most common conditional statement is naturally the if statement. It's easy to use and can be combined with an else clause to handle failed tests. It's written like this:

 
if (expression) statement;
e.g.
    if (a == 5)
        a -= 4;

If you want to handle the failed match, you add an else statement like this:

 
if (expression) true-statement else false-statement;
e.g.
    if (a == 5)
        a -= 4;
    else
        a += 18;



This document was generated by Hekay Permer on April, 20 2005 using texi2html