Solution Review: Multiple Return Values

This lesson discusses the solution to the challenge given in the previous lesson.

package main
import (
"fmt"
)
func SumProductDiff(i, j int)(s int, p int, d int) {
s, p, d = i + j, i * j, i - j
return
}
func main() {
sum, prod, diff := SumProductDiff(3, 4)
fmt.Println("Sum:", sum, "| Product:", prod, "| Diff:", diff)
}

Get hands-on with 1200+ tech skills courses.