1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Go】配列のサンプルメモ

Posted at
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)
}
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?