在我正在编写的打印函数中,我试图根据 switch 语句的结果返回一个值;但是,我收到错误太多参数无法返回。
如果这个问题有一个简单的答案,请原谅我,但是一个函数有多少个参数并且它只能返回一件事难道不应该无关紧要吗?或者它是否需要为每个参数返回一件事。
这是我的代码。我在返回行上遇到错误(返回的参数太多)。如何修复它以便它返回 switch 语句中设置的字符串?
package bay
func Print(DATA []TD, include string, exclude []string, str string) {
result := NBC(DATA, include, exclude, str)
var sentAnal string
switch result {
case 1:
sentAnal = "Strongly Negative"
case 2:
sentAnal = "Very Negative"
case 3:
sentAnal = "Negative"
case 4:
sentAnal = "Little Negative"
case 5:
sentAnal = "Neurtral"
case 6:
sentAnal = "Little Positive"
case 7:
sentAnal = "Positive"
case 8:
sentAnal = "More Positive"
case 9:
sentAnal = "Very Positive"
case 10:
sentAnal = "Strongly Positive"
default:
sentAnal = "Unknown"
}
return sentAnal
}
关于函数多参数返回值?
返回json数据浏览器会自动下载,无法查看,如何解决
出现问题,当使用?number=xxx的时候,总能返回一个string,许是因为单个的缘故吧,但是如果我以sex or job or name则返回的全都是“参数错误”,何解??
如何解决jade的缩进问题
相关分类