在我正在编写的打印函数中,我试图根据 switch 语句的结果返回一个值;但是,我收到错误太多参数无法返回。如果这个问题有一个简单的答案,请原谅我,但是一个函数有多少个参数并且它只能返回一件事难道不应该无关紧要吗?或者它是否需要为每个参数返回一件事。这是我的代码。我在返回行上遇到错误(返回的参数太多)。如何修复它以便它返回 switch 语句中设置的字符串?package bayfunc 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}
3 回答
- 3 回答
- 0 关注
- 268 浏览
添加回答
举报
0/150
提交
取消