LoginSignup
0
0

More than 5 years have passed since last update.

関数で戻り値を指定する

Posted at

 return文への指定を省略

golangでは戻り値に変数を割り当てると、return文へ指定する戻り値を省略可能。
つまり、次のような関数fooはa,bを正しく返す。

foo.go
func foo() (a, b int){
  a = 1
  b = 2
  return
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0