Skip to content
Justice Tech School

Slices of Slices

A slice of slices builds a grid.

Example
package main

import "fmt"

func main() {
	g := [][]int{{1, 2}, {3, 4}}
	g = append(g, []int{5, 6})
	for _, row := range g {
		fmt.Println(row)
	}
}

Result

[1 2]
[3 4]
[5 6]

Exercise

Grid type.

[]int

Quiz Test

What is g[1][0]?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.