Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@kure

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

More than 1 year has passed since last update.
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)
}
0
Help us understand the problem. What is going on with this article?
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
kure

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?