This commit is contained in:
Aliberk Sandıkçı 2023-07-12 11:22:32 +03:00
parent b35ac2c1c9
commit 9d276f8094

26
2moretypes/array.go Normal file
View 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")
}