The If Statement

From Catglobe Wiki
Revision as of 08:15, 14 December 2011 by Cg pham (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



The If Statement

The complete syntax of the if statement is:

if (condition) statement;

else statement;

where the targets of the if and else are single statements. The else clause is optional. The targets of both the if and else can be blocks of statements. The general form of the if using blocks of statements is:

if (condition)

{

Statement sequence

}

else

{

Statement sequence

}

Here is a simple example that uses simple if and else statements:

{

if (SomeValue == 0) print("value == 0");

else print("value != 0");

}

An else statement always refers to the nearest if statement that is within the same block as that else and not already associated with another else.