Condition Keywords
Keywords that allow execution based on a condition.
There are 3 condition keywords. These run a statement based on a condition.
Condition statements are designed to be followed by a block section.
If
If statements run a statement if and only if a check passes.
If statements will conform the check result to a boolean (true/false) value.
True | False |
---|---|
|
|
Any non-zero number. | A zero value. |
Any non-null object. |
|
This means that statements like the following are valid and correct.
While
While statements run a statement as long as a check passes.
Unless something changes to make the check false, a while statement will run forever.
While statements will conform the check result to a boolean (true/false) value.
For
For statements run a statement once for every value in a collection of values.
Although there is no explicit check, a for
statement is a special while
statement internally.
For statements are useful for iterating (looping) over a number of values.
Last updated