I want to return just 1 value to the function with multiple return values. I tried this:
func myFunc() (int, int){
return _, 3
}
But it didn't work and raised this error: cannot use _ as value
I already know that It's possible to receive one of the returned values.
Is there any way to return just 1 value?
Use the zero value for the other return parameters:
If you use named result parameters, you may also do:
In this case
xwill also be the zero value of its type,0in case ofint.You could also write a helper function which adds a dummy return value, e.g.:
But personally I don't think it's worth it. Just return the zero value for "unused" return parameters.