返回值作为参数为多 - argument functions
考虑以下代码:If we attempt to pass the return values of returnIntAndString() to doSomething() directly:
doSomething("message", returnIntAndString())Go will complain with the错误:func returnIntAndString() (i int, s string) {...}
func doSomething(msg string, i int, s string) {...}
可以解决此问题,您有两个选项,您有两个选项:
doSomething("message", returnIntAndString())
[&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&得到,请记住,GO的特定规则不允许在分配参数时与多值返回值函数一起允许其他参数。如果未满足语言规范中概述的特定条件,则必须采用提供的解决方案之一。 免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3