If

From Mesham
Revision as of 16:18, 31 December 2009 by Polas (talk | contribs) (Created page with '== Syntax == if (condition)<br> {<br> then body<br> } else {<br> else body<br> };<br> == Semantics == Will evaluate the condition and, if true will execute the code in the ''t…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Syntax

if (condition)
{
then body
} else {
else body
};

Semantics

Will evaluate the condition and, if true will execute the code in the then body. Optionally, if the condition is false then the code in the else body will be executed if this has been supplied by the programmer.

Example

if (a==b)
{
   print["Equal"];
};

In this code example two variables a and b are tested for equality. If equal then the message will be displayed. As no else section has been specified then no specific behaviour will be adopted if they are unequal