Access elements by their index:
nums := [5]int{10, 20, 30, 40, 50}
fmt.Println(nums[0]) // 10
fmt.Println(nums[4]) // 50
nums[2] = 35
Indices start at . The last element is at index length-. Accessing an index outside bounds causes a panic.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Using indices
Access elements by their index:
nums := [5]int{10, 20, 30, 40, 50}
fmt.Println(nums[0]) // 10
fmt.Println(nums[4]) // 50
nums[2] = 35
Indices start at . The last element is at index length-. Accessing an index outside bounds causes a panic.