Go concurrent appointment

I'm learning Go and can't understand one thing, why do the creators of this language support simultaneous assignment? It is very easy to make mistakes, such as a, b = a, b, not a, b = b, a, as I would like, well in advance for any good explanations.

+5
source share
2 answers

It's very easy to make mistakes like a, b = a, b, not a, b = b, a,

If simultaneous assignment was not available, you would need to do something else instead. An alternative approach might look something like this:

tmp = a
a = b
b = tmp

It is much easier if you are mistaken.

+13
source

, , , & hellip; ?

+8

All Articles