Woo! Good choice, math it is. In most programming languages there are at least 5 groups of operators: arithmetic, assignment, increment/decrement, comparison, logical. ColdFusion has all of these operators, but we won’t get to crazy and we will only deal with the first 3.
Arithmetic Operators
Arithmetic operators in ColdFusion are super simple and work just as expected in almost any other language. There is no special integer division or characters that you have to deal with.
See? I told you there is nothing special here, they are pretty much standard across most languages.
It is sometimes be useful to join strings. You might want to consider consider just outputting them both right next to each other. Sometimes, you just want to merge to strings into a new variable, but you cannot use the + sign when joining string. However, you can use the & to join strings or strings and numbers.
Assignment Operators
Listen up, I will save you a good amount of time by knowing how to use assignment operators. All assignment operators involve the = mixed with an operator to symbolize that you are using both at the same time. It tells ColdFusion that you want to do whatever the operator is to the following value to the current value. It will be easier to understand with an example:
Notice how we didn’t have declare the variable on the right hand side of the statement. This is exactly what the assignment operators eliminate. Obviously, it wouldn’t too helpful if this just applied to addition. You can use all of the arithmetic operators in the exact same fashion as we just used the addition operator. Of course, you don’t have to use them. You could always write assignmentVar = assignmentVar + 5. But, come on. We are coders, and we are proud to be lazy.
Increment and Decrement Operators
Four possible outcomes occur from increments and decrements. Notice the placement of the increment or decrement operator around the variable.
If you have ever messed with these guys before, you know what is going on here. If not, just understand that the position of the increment or decrement operator tells us when the action on the variable happens. In the first example, ++a, increments the variable before we print it out. However, in the second example, b++, we don’t increment the variable until after we print it to the screen. It’s a little bit complicated, but it is rather rare to use the incrementing or decrementing before the variable.
Hello since I do not know what the ++ signs in front of the a can you define those as well as the — signs?