Prev | Current Page 139 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


You can also test to see if expressions are greater than ( > ), greater than or equal ( > = ), less than ( < ), or less
than or equal ( < = ). For example:
var myBoolA : Bool = (1 < 2);
var myBoolB : Bool = (1 > = 2);
Chapter 3: Learning the Basics
59
In this example, myBoolA will be true , as 1 is smaller than 2, but myBoolB will be false , as 1 is not
greater or equal to 2.
Logical AND and OR
If you need to compare the values of more than one logical comparison, you can join the comparisons
using the logical AND ( & & ) or logical OR ( || ) operators. The logical AND will only return true if both
expressions on either side are true, while the logical OR will return true if either of the expressions are
true:
var myBoolA : Bool = (1 < 2) & & (2 == 2);
var myBoolB : Bool = (2 > = 4) || (3 < 4);
In this example, myBoolA will be true , as 1 is less than 2 and 2 is equal to 2. The logical AND operator
required both expressions to be true, so it was able to return true . myBoolB is also true , as although 2 is
not greater than or equal to 4, 3 is less than 4, so the OR operator will return true .


Pages:
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151