I'm learning Go and can't understand one thing, why creators of this language do support simultaneous assignment? It is very easy to make mistakes like a, b = a, b and not a, b = b, a, as I would want, thanks in advance for any good explanations.
It is very easy to make mistakes like a, b = a, b and not a, b = b, a,
If simultaneous assignment were not available then you would have to do something else instead. An alternative approach might look something like this:
tmp = a
a = b
b = tmp
That's much easier to get wrong.
How else would you get access to the second, third, fourth, … return value of a function?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With