在我正在編寫的打印函數中,我試圖根據 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 回答
- 0 關注
- 302 瀏覽
添加回答
舉報
0/150
提交
取消