这个简单的脚本怎么了? [英] What's wrong with this simple script?
本文介绍了这个简单的脚本怎么了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我学习了函数,为教科书写了一个简单的脚本,有两个错误.
I study functions, wrote a simple script for the textbook, and there were 2 errors.
package main
import "fmt"
func zero(x int) {
x = 0
return x
}
func main() {
x := 5
x = zero(x)
fmt.Println(x)
}
要返回的参数太多(字符串返回x)
too many arguments to return (string return x)
太多"了吗?只有一个!
How is "too many"? It's only one!
零(x)用作值(字符串x =零(x))
zero(x) used as value (string x = zero(x))
我不明白他对我说的话.
I don't understand what he says to me.
推荐答案
int in func
int in func
package main
import "fmt"
func zero(x int) int {
x = 0
return x
}
func main() {
x := 5
x = zero(x)
fmt.Println(x)
}
这篇关于这个简单的脚本怎么了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文