Add guidelines on multiple assignments in a single line
Sometimes one might want to do multiple assignments in a single line to reduce number of lines of code, e.g.
Pmin, Pmax = get_pmin(fnm.system), get_pmax(fnm.system)
If this is considered bad style by us, we should probably add a comment about this in the docs.
I think multiple assignments from a single call is okay (unpacking):
a, b, c = f()
but multiple assignments from multiple calls should probably be avoided.
I agree with omus.
What about the following pattern:
a, b, c = if cond(x)
alpha, beta, gamma
else
nothing, f(beta), g(gamma)
end
IIRC there are cases where one assignment outside an if statement infers better than separate assignments inside it.
That case seems beyond the scope of this issue. Since this is about multiple assignments on a single line." I agree that for blocks it can be occasionally useful.
the reason i don't like it is for:
a, b = c(), d()
the reading order I end up having is either: a, c, b, d or c, a, d, b.
Because I want to know what is assigned to what.
both of which are easier with
a = c()
b = d()
I guess another way to describe this rule would be "Do not create tuples just to unpack them on the same line" ?