Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 07:15, 14 December 2011 by Cg_pham (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



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.