on the list - Arrays - elements, index, Array literals
Head First Go、 Jay McGavren(著)、O’Reilly Media)の Chapter 5(on the list - Arrays)、p.154(Exercise)の解答を求めてみる。
コード
main.go
package main
import "fmt"
func main() {
var numbers [3]int
numbers[0] = 42
numbers[2] = 108
var letters = [3]string{"a", "b", "c"}
fmt.Println(numbers[0] == 42)
fmt.Println(numbers[1] == 0)
fmt.Println(numbers[2] == 108)
fmt.Println(letters[0] == "a")
fmt.Println(letters[1] == "b")
fmt.Println(letters[2] == "c")
}
入出力結果(Terminal, Zsh)
% go run ./main.go
true
true
true
true
true
true
%