x, y = 1, 2, 3
behaves the same as x, y = 1, 2
Also x, = 3
behaves the same as x = 3
Are they a feature?
In python both would trigger exceptions, which I think is better.
x, y = 1, 2, 3
behaves the same as x, y = 1, 2
Also x, = 3
behaves the same as x = 3
Are they a feature?
In python both would trigger exceptions, which I think is better.
Yes, this is a feature. Not sure which is better.
One arguable benefit of this syntax is that one can easily discard unneeded function return values:
julia> f()=(1,2,3);
julia> x,=f();
julia> x
1
x, = 3
works because numbers are iterable. There’s a concurrent discussion about that: Numbers as single-element collections
I definitely see the current behavior as an advantage. It means, among other things, that I can add more outputs to an existing function, without breaking all code that calls that function.
I do this frequently in Matlab, and expect that it will happen with Julia too.