Recently, I studied that Golang can return multiple result for a function. So I write a function:
func store(x, y int) (int, int) {
return x + y, x - y
}
After this I write the following code:
func main() {
a, b := store(6, 4)
fmt.Println(a, b)
}
And, the result is:
10 2
This is working fine.
But if I want to print only a, then how can I do this?
func main() {
a, b := store(6, 4)
fmt.Println(a)
}
Result:
tmp/sandbox683412938/main.go:12:19: b declared and not used
Also, why I can't write:
func main() {
a := store(6, 4) // ???
fmt.Println(a)
}
Please, guide me.