LoginSignup
28
16

More than 5 years have passed since last update.

Goで二次元配列の初期化を一行で行う

Posted at

正確にはスライスのスライスです

matrix := [][]float64{{0, 0}, {0, 1}, {1, 0}, {1, 1}}

以下と等価

matrix := make([][]float64, 4)
matrix[0] = []float64{0, 0}
matrix[1] = []float64{0, 1}
matrix[2] = []float64{1, 0}
matrix[3] = []float64{1, 1}
fmt.Println(matrix) // [[0 0] [0 1] [1 0] [1 1]]

28
16
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
28
16