In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable.
In most imperative programming languages, the assignment statement (or expression) is a fundamental construct.
Sometimes they are required, either because only a single statement is available (e.g.
in an if statement) or because the values will change after the statement (e.g. All values on the right-hand side of the assignment operator are evaluated before the assignment is performed.
The set of values allowed to store in variable is determined by the variable’s type.
Because of that arbitrary data can’t be just assigned as in dynamically typed language like Python.
I think it would be easier to just use a more traditional for loop.
While it probably doesn't matter for such a small array, I'm not sure if the compiler would optimize away the actual array accesses and I'd rather not rely on a trick.
It’s easy to create well-maintained, Markdown or rich text documentation alongside your code.
Sign up for free See pricing for teams and enterprises Simultaneous assignment is useful in many cases to make related assignments in a single statement.