LoginSignup
1
0

More than 3 years have passed since last update.

競プロで使うための GO 入門 ~関数~

Last updated at Posted at 2020-07-18

Index

関数定義と呼び出し

package main

import(
    "fmt"
)

// 関数
func add(a int, b int) int {
    return a + b
}

// メイン
func main() {
    fmt.Println(add(1, 2)) // ->3
}

複数の戻り値

// 関数
func div(a int, b int) (int, int) {
    return a / b, a % b
}

// メイン
func main() {

    fmt.Println(div(8, 3)) // ->2 2
}
1
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
1
0