17 lines
301 B
Go
17 lines
301 B
Go
// the length is not part of the type for a slice
|
|
|
|
// slices use the same syntax as arrays for accessing/assigning
|
|
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
// []int makes a slice, [...]int makes an array
|
|
x := []int{10, 20, 30}
|
|
fmt.Println(x)
|
|
|
|
x = []int{1, 5: 4, 6, 10: 20, 11}
|
|
fmt.Println(x)
|
|
}
|