Skip to content

Instantly share code, notes, and snippets.

@giwa
Created February 5, 2015 17:25
Show Gist options
  • Save giwa/03e007b3714f03532475 to your computer and use it in GitHub Desktop.
Save giwa/03e007b3714f03532475 to your computer and use it in GitHub Desktop.
Go by Examples: Multiple Return Values ref: http://qiita.com/giwa@github/items/2789d0ddf86bffb37f9f
package main
import "fmt"
//この関数において(int, int)はこの関数は2つのintを返すことを示します。
func vals() (int, int) {
return 3, 7
}
func main() {
   // ここでは、複数に代入する関数の呼び方から2つの違った値を受け取ります。
a, b := vals()
fmt.Println(a)
fmt.Println(b)
  // もし返り値の一部を使いたい場合は、_を使ってください。
_, c := vals()
fmt.Println(c)
}
$ go run multiple-return-values.go
3
7
7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment