Document assignment syntax #8191
Labels
docs
This change adds or pertains to documentation
good first issue
Indicates a good issue for first-time contributors to Julia
I believe the documentation does not describe the syntax of the assignment operator. From examples, I know that e.g.
is possible. However, I don't know whether this is a special syntax for assignment, or whether LHS and RHS are implicitly interpreted as tuples.
I found out the hard way that writing
interprets x as iterable, leading to a very strange error about a method "start" when x returns a value that is not iterable. Apparently, assignment to a tuple can automatically convert e.g. from lists -- naively, I would have expected that I have to call a function for this.
I also found out that
is possible, and silently discards the additional value. I would have expected a warning in this case.
Finally, I somehow expected that "_" (using an underscore as variable name) is a placeholder that I can use to discard values, as in
However, this instead creates a local variable called "_".
Since I did not expect these behaviours, others may be surprised as well. It would be good to describe them in the documentation.
The text was updated successfully, but these errors were encountered: