Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Glish provides C-style if and if ... else conditionals:
if ( expression ) statement
if ( expression ) statement1 else statement2An if statement evaluates expression, converts the result to a boolean value, and if true executes statement. The if ... else statement is similar, executing statement1 if the value is true and statement2 if false. The expression should evaluate to a scalar value; if it is a vector then its first element is tested, though in the future an error may be generated instead.
As in most languages, a ``dangling-else'' is associated with the nearest previous if, so
if ( x ) if ( y ) print "x and y" else print "either not x or not y"is interpreted as:
if ( x ) { if ( y ) print "x and y" else print "either not x or not y" }and not as:
if ( x ) { if ( y ) print "x and y" } else print "either not x or not y"