package main
import (
"fmt"
)
func main() {
// 配列の型
// [長さ] 要素型
// [長さ] 要素型 {要素の初期値..}
// 配列の宣言
var arr1 [2]string
arr1[0] = "a"
arr1[1] = "b"
fmt.Println(arr1)
// 配列初期化
arr2 := [2]string{"a", "b"}
fmt.Println(arr2)
// https://yttm-work.jp/lang/go/go_0005.html#head_line_03
var arr3 [2]string = [2]string{"a", "b"}
fmt.Println(arr3)
// 初期値で指定した要素の数が自動的に長さとなる
arr4 := [...]string{"a", "b"}
fmt.Println(arr4)
}
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme