Arrays
This commit is contained in:
parent
b35ac2c1c9
commit
9d276f8094
1 changed files with 26 additions and 0 deletions
26
2moretypes/array.go
Normal file
26
2moretypes/array.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
fmt.Println("var VAR_NAME [SIZE] DATA_TYPE")
|
||||
fmt.Println("blank indexes are 0 for numerics and empty string for strings")
|
||||
|
||||
var a [3]string
|
||||
a[0] = "zero"
|
||||
a[1] = "one"
|
||||
fmt.Println(a[0], a[1])
|
||||
fmt.Println(a)
|
||||
|
||||
fmt.Println("You can also declare a variable as an array like this")
|
||||
negative := [10]int{1, 2}
|
||||
|
||||
fmt.Println(negative)
|
||||
fmt.Println(reflect.TypeOf(negative))
|
||||
|
||||
fmt.Println("Array cannot be resized!!! Instead slices can be used")
|
||||
}
|
Loading…
Reference in a new issue