gobyexample/21-returns.go
2012-09-20 20:49:36 -07:00

23 lines
404 B
Go

// A function can return multiple values.
package main
import "fmt"
func vals() (int, int) { // The `(int, int)` in this signature shows that the
return 3, 7 // function returns 2 ints.
}
func main() {
x, y := vals() // Use the 2 different return values from the call.
fmt.Println(x)
fmt.Println(y)
}
/*
$ go run 21-returns.go
3
7
*/