myArray :=[...]int{12,14,26}
As stated by the previous commenters, :=
is a type of short-hand and/or the short-form of variable declaration.
So in the statment above you are doing two things.
- You are declaring your variable to be myArray.
- You are assigning an array of integers to the myArray variable.
The second part of your code fails, because what you are doing here:
myArray :=[...]int{11,12,14} //error pointing on this line
Is RE-declaring the existing variable myArray, which already contains integer values.
This works:
myArray = [...]int{11,12,14} // NO error will be produced by this line
Because, it is assigning the integer array to the existing ( pre-declared / initialized ) variable.