Expressions
Expressions allow us to combine or modify variables, such as addition, subtraction, etc.
We already looked at one type of expression, which is the set expression. This assigns a value to a variable.
We can modify this float variable through addition, subtraction, division, multiplication expressions.
Parentheses can be used to specify operation priority as in the third example.
Be careful not to perform operations on incompatible types. This would throw an error:
You can't add a vector and an int together! Instead, lets convert the int to vector first before adding them.
This will print out "5, 5, 5".
We can reference other class fields or method calls in our expressions.
Finally, we can use some symbols to modify bool values. They include the following:
== (equals)
!= (not equals)
|| (or)
&& (and)
! (not)
< (less than)
>(greater than)
<= (less than or equal)
>= (greater than or equal)
Last updated