Returning multiple values from a function is a common idiom in Go, most often used for returning values along with potential errors. We‘ll go over how to return multiple values from a function and use those values in our program. // You c
Returning multiple values from a function is a common idiom in Go, most often used for returning values along with potential errors. We‘ll go over how to return multiple values from a function and use those values in our program.
// You can edit this code! // Click here and start typing. package main import "fmt" func inc (n int) int { return n + 1 } func timesTwo (n int) int { return n * 2 } func plusOneTimestwo (n int) (int, int) { return inc(n), timesTwo(n) } func main() { n, m := plusOneTimestwo(3) // assign to variables fmt.Println(n, m) // 4, 6 }