Prev | Current Page 169 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The conditional expression is supplied in
brackets after the if keyword. If the expression returns true , then the statement of code following the
expression is executed:
if ( 3 == 3 )
someVar = someValue;
// rest of application
Chapter 4: Controlling the Flow of Information
75
If you have more than one statement you want executed following a true expression, you can form a
block by surrounding those lines of code with curly braces { and } :
if ( 3 == 3 )
{
someVar = 1;
someVar++;
}
// rest of application
The line or block of code following an if statement is only executed if the statement returns true . You
can reverse the return value of a conditional expression by supplying an opposing conditional operator,
or by negating the entire expression with the negation operator ( ! ):
if ( 3 != 3 )
// do this...
The preceding code is the same as:
if ( ! 3 == 3 )
// do this...
The negation operator alters the return value of a conditional expression so that true will be returned
instead of false , and false returned instead of true .


Pages:
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181