From 9d276f809475995ef8f860106aa3109a5dacacb3 Mon Sep 17 00:00:00 2001 From: asandikci Date: Wed, 12 Jul 2023 11:22:32 +0300 Subject: [PATCH] Arrays --- 2moretypes/array.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 2moretypes/array.go diff --git a/2moretypes/array.go b/2moretypes/array.go new file mode 100644 index 0000000..6a541a7 --- /dev/null +++ b/2moretypes/array.go @@ -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") +}