Arrays
Examples
Filter
package main
import "fmt"
func main() {
var a [5]int
fmt.Println("emp:", a)
a[4] = 100
fmt.Println("set:", a)
fmt.Println("get:", a[4])
fmt.Println("len:", len(a))
b := [5]int{1, 2, 3, 4, 5}
fmt.Println("dcl:", b)
var twoD [2][3]int
for i := 0; i < 2; i++ {
for j := 0; j < 3; j++ {
twoD[i][j] = i + j
}
}
fmt.Println("2d: ", twoD)
}
module main
fn main() {
numbers := [1, 2, 4, 5, 6, 7, 8, 9, 10]
println(numbers)
friends := ['Alex', 'Nedpals', 'Joe', 'Spytheman']
println(friends)
mut empty_numbers := []int{}
empty_numbers << 20
empty_numbers << 30
println(empty_numbers)
}
Last Run
:
[1, 2, 4, 5, 6, 7, 8, 9, 10]
['Alex', 'Nedpals', 'Joe', 'Spytheman']
[20, 30]