I'm trying to return a variable along with a function that returns multiple values.
Consider this contrived example:
func twoInts() (int, int) {
return 2, 3
}
func threeInts() (int, int, int) {
return 1, twoInts()
}
Calling threeInts() returns "multiple-value twoInts() in single-value context".
I understand I can do the following
func twoInts() (int, int) {
return 2, 3
}
func threeInts() (int, int, int) {
num1, num2 := twoInts()
return 1, num1, num2
}
but I am trying to understand why the return is a single-value context.
Does Go consider the return to be
int, (int, int)
? Is there a way to expand the first function return so that it does return int, int, int
?