|
PowerScript provides the following shortcuts you can use to assign values to variables. They have slight performance advantages over their equivalents:
|
This assignment shortcut
|
Used here
|
Is equivalent to
|
|
++
|
i ++
|
i = i + 1
|
|
--
|
i --
|
i = i - 1
|
|
+=
|
i += 3
|
i = i + 3
|
|
-=
|
i -= 3
|
i = i -3
|
|
*=
|
i *= 3
|
i = i * 3
|
|
/=
|
i /= 3
|
i = i / 3
|
|
^=
|
i ^=3
|
i = i ^ 3
|
If you allow dashes in variable names, leave a space before -- and -= (if you don't, PowerScript considers the minus sign part of a variable name).
Tip You can use the assignment shortcuts only in assignment statements. They cannot be used with other operators in a statement.
Examples
These are valid assignment statements:
The last assignment statement below is invalid, because ++ is not used by itself in the assignment:
int i, j i = 12 j = i ++ // INVALID, ++ is not used by itself.
The following statement using ++ is valid, because ++ is used by itself in the assignment:
int i, j i = 12 i ++ //VALID, ++ is used by itself j = i
Related topic
|