Help us understand the problem. What is going on with this article?

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

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)
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした