Categories
Data Structure and Algorithm

Slice of Slice

https://play.golang.org/p/3HpTAxoPC6l

// in Go Data Structures and algorithms book
package main

// importing fmt package
import (
	"fmt"
)

// main method
func main() {
	var rows int
	var cols int
	rows = 7
	cols = 9
	
	// rows := 7
	// cols := 9
	
 	var twodslices = make([][]int, rows)
	var i int
	for i = range twodslices {
		twodslices[i] = make([]int, cols)
	}
	fmt.Println(twodslices)
}