-
|
I understand that the assignment operator Would this be the proper way to initialize |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
No, swapping wouldn't be the proper way. A better way is simply to make more variables, as variables are initialized to 0 by default. Variable values can't be overwritten; This is why in loops, arrays are used ( It doesn't have: |
Beta Was this translation helpful? Give feedback.
No, swapping wouldn't be the proper way.
A better way is simply to make more variables, as variables are initialized to 0 by default.
Another way is XOR again (as in this example), as XOR is its own inverse.
Variable values can't be overwritten;
^=is equivalent to initialization if the variable holds value0.This is why in loops, arrays are used (
for_32.src):It doesn't have:
c ^= (a[$i] + b[$i])orc ^= (a[$i] - b[$i]), ∵ that doesn't mean "overwrite variablecwith the RHS" (as it would if^=