I found the following feature by accident. In one of my program I converted a one dimensional array to a two dimensional one and forgot to add the second dimension in one place. Surprisingly (to me) the compiler didn’t flag it.
I was in the process of creating a short program to report the problem when I realized it seems to be a feature. You can initialize an entire array or an entire array dimension by assigning it a single value. I checked the overview and Understanding the Odin Programming Language but couldn’t find a reference to that type of initialization.
xs: [2][10]int
xs[0] = 10
xs[1] = 20
fmt.printf(“xs: %d, %d, %d\n”, xs[0][9], xs[1][0], xs[1][9])
==> xs: 10, 20, 20
ys: [10]int
ys = 5
fmt.printf(“ys: %d, %d\n”, ys[0], ys[9])
==> ys: 5, 5
I am just curious if this is described anywhere.
Thanks