Shortcuts
When you create a variable and set it equal to a value the equal sign is called an assignment operator.
There are some operators the can evaluate an operation and assign a value at the same time.
This shorthand operation is created by using a math operation and an equal sign next to each-other.
x += 12 is equal to x = x + 12
x %= 3 is equal to x = x%3
Note: The variable must have an initial value
When you create a variable and set it equal to a value the equal sign is called an assignment operator.
There are some operators the can evaluate an operation and assign a value at the same time.
This shorthand operation is created by using a math operation and an equal sign next to each-other.
x += 12 is equal to x = x + 12
x %= 3 is equal to x = x%3
Note: The variable must have an initial value
|
|
Other Types This can also be used on Strings. |
Increments
This is very useful when we want to increase a variables value by increments.
This is very useful when we want to increase a variables value by increments.