gobyexample/014-multiple-return-values/multiple-returns-values.go
Mark McGranaghan 1c63eb272c fix
2012-09-23 14:50:32 -07:00

25 lines
517 B
Go

// ## Multiple Return Values
// In Go, a function can return multiple values.
// This feature is used often, for example to
// return a result and an error from a function.
package main
import "fmt"
// The `(int, int)` in this signature shows that the
// function returns 2 ints.
func vals() (int, int) {
return 3, 7
}
func main() {
// Use the 2 different return values from the call,
// i.e. multiple assignement.
x, y := vals()
fmt.Println(x)
fmt.Println(y)
}