Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习 Go 并且无法理解一件事,为什么这种语言的创建者支持同时分配?正如我想要的那样,很容易犯像 a, b = a, b 而不是 a, b = b, a 这样的错误,提前感谢任何好的解释。
很容易犯错误,比如 a, b = a, b 而不是 a, b = b, a,
如果同时分配不可用,那么您将不得不做其他事情。另一种方法可能如下所示:
tmp = a a = b b = tmp
这更容易出错。
否则您将如何访问函数的第二个、第三个、第四个……返回值?