GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
sample-golang
/
01_hello
Browse code
remove unnecessary files
master
1 parent
fdd217c
commit
ae659b6f62ff6b3ee71e0e4c3e61d96d217dc16c
yhornisse
authored
on 25 Sep 2021
Patch
Showing
2 changed files
array.go
slice.go
Show notes
View
array.go
100644 → 0
package main import "fmt" func main() { var a[3]int // 要素の値を省略したらゼロ値 fmt.Printf("a: %+v\n", a) // [0, 0, 0] b := [3]int{1, 2, 3} fmt.Printf("b: %+v\n", b) // [1, 2, 3] c := [3]int{1, 2} fmt.Printf("c: %+v\n", c) // [1, 2, 0] d := [3]int{2: 2} fmt.Printf("d: %+v\n", d) // [0, 0, 2] e := [3]int{0:1, 1: 2} fmt.Printf("e: %+v\n", e) // [1, 2, 0] // 要素が比較可能であればその配列型も比較可能 fmt.Printf("a==b: %v\n", a == b) // false fmt.Printf("c==e: %v\n", c == e) // true // f := [4]int{} // fmt.Printf("a==f: %v\n", a == f) // compile error: [3]int == [4]int hoge(a) fmt.Printf("a: %+v\n", a) // [0, 0, 0] } func hoge(arg [3]int) { arg[0] = 4 fmt.Printf("%+v\n", arg) // [4, 0, 0] // 値渡しなので安全だが性能的に非効率なことがある }
Show notes
View
slice.go
100644 → 0
package main import "fmt" func main() { fmt.Println("Hello, World") }
Show line notes below