Hoping to understand maps in Go better.
Given this code:
package main
import "fmt"
type Vertex struct {
Lat, Long float64
}
var m []map[string]Vertex
var m1 map[string]Vertex
func main() {
m = make([]map[string]Vertex, 3)
m1 = make(map[string]Vertex)
m1["Bell Labs"] = Vertex{
40.68433, -74.39967,
}
m = append(m, m1)
fmt.Println(m)
fmt.Println(len(m))
fmt.Println(m[3]["Bell Labs"])
}
I get an output of
[map[] map[] map[] map[Bell Labs:{40.68433 -74.39967}]]
4
{40.68433 -74.39967}
Why is it that the first 3 elements in the array are empty/null maps, shouldn't it print out [map[Bell Labs:{40.68433 -74.39967}]]
instead?