Is it possible a) to define b) to initialize a new multidimensional array using the existing array, as in the following code instead of var b [2][3]int , just saying something like var b [2]a ?
Using the type, whatever it may be, instead of hard coding (which skips the point of use [...] for a).
And perhaps initialization processing = copying values ββat the same time?
package main func main () { a := [...]int{4,5,6} var b [2][3]int b[0],b[1] = a,a }
(I know the ease and convenience of slicing, but this question is about understanding arrays.)
Edit: I can't believe I forgot about var b [2][len(a)]int , freezing the brains of beginners. One answer would be var b = [2][len(a)]int{a,a} . What type conversion is right?
source share