Logo

Programming-Idioms

History of Idiom 26 > diff from v39 to v40

Edit summary for version 40 by programming-idioms.org:
[Go] Same dimensions as picture

Version 39

2018-05-09, 01:42:13

Version 40

2018-05-09, 20:32:38

Idiom #26 Create a 2-dimensional array

Declare and initialize a matrix x having m rows and n columns, containing real numbers.

Illustration

Idiom #26 Create a 2-dimensional array

Declare and initialize a matrix x having m rows and n columns, containing real numbers.

Illustration
Code
const m, n = 2, 3
var x [m][n]float64
Code
const m, n = 3, 4
var x [m][n]float64
Comments bubble
m, n must be constant for this syntax to be valid.
Here x is of type [2][3]float64, it is not a slice.
Comments bubble
m, n must be constant for this syntax to be valid.
Here x is of type [3][4]float64, it is not a slice.
Demo URL
http://play.golang.org/p/cAqJGf9q1y
Demo URL
https://play.golang.org/p/bm0IVTCBiu2