4. Go Array Basics
Arrays are a data structure with a fixed size and type.
Creating arrays:
var VARIABLE_NAME = [INT]TYPE{}
var bag = [10]string{}
Sample:
package main
import "fmt"
type tables struct {
name string
age int64
cash int64
}
var arrays = [5]tables{}
var intarray = [5]int{}
var stringarray = [5]string{}
// var variable [indexlimit]type{values}
// var variable [...]type{values}
func main() {
arrays[0] = tables{"bob", 64, 300}
fmt.Println(array[0].age)
}
Comments
Post a Comment