Prev | Current Page 141 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

..else
commands in Chapter 4 , ??? Controlling The Flow Of Information. ???
Assignment Operators
So far, you have only seen one of the assignment operators, the `=` operator. This is known as the
assignment operator. However, this is not the only assignment operator available in the haXe language.
When working with numerically typed variables, it is common to have to perform mathematical
operations using other numerically typed variables or literal values and re - assign the value back into one
of the numerical variables. Just as you can increase or decrease a variables value by one using the
increment and decrement operators, you can also perform mathematical equations on a variable using a
similarly styled set of assignment operators. For example, to increase a variables value by one, rather
than using the increment operator, you could use the addition assignment operator ( += ), like this:
count += 1;
Part I: The Core Language
60
As you can see, this expression is very similar to assigning the value 1 to a variable, however, the
addition symbol before the assignment symbol states that you want to add the 1 to the existing value of
the count variable and then assign the result of that equation into count .


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