Arrays and Slices
Create an array
// create an array with can store [4] values
// of type float64
// {assign values}
prices := [4]float64{10.99, 5.99, 34.94, 20.45}// This array holds only null values, in this case 3x "" because we didn't
// give any value to this array
var productNames [3]stringIndex of an array
// First value of the array is now "Space", the others still remain "".
productNames[0] = "Space"Subset of Arrays with slices
prices := [4]float64{10.99, 5.99, 34.94, 20.45}
firstTwoPrices := prices[0:2]
// Output:
[10.99 5.99]Arrays and slices, what's the difference?
Array/Slice methods
Dynamic Lists with Slices
Unpacking List values
Loop through Arrays / Slices
Last updated