Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
869 views
in Technique[技术] by (71.8m points)

go - How to solve "too many arguments to return" issue

In a print function I am writing, I am trying to return a value based on the result of a switch statement; however, I am getting the error too many arguments to return.

Forgive me if this question has a simple answer, but shouldn't it not matter how many arguments a function has and it can return just one thing? Or does it need to return one thing for each argument.

Here is my code. I am getting an error on the return line ( Too many arguments to return ). How can I fix it so that it returns the string set in the switch statement?

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
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...