map
package main
import "fmt"
type Student struct {
Name string
}
var list map[string]Student
func main() {
list = make(map[string]Student)
student := Student{"Aceld"}
list["student"] = student
list["student"].Name = "LDB"
fmt.Println(list["student"])
}
Answer
Try it
compilation error
cannot assign to struct field list["student"].Name in map
map1
package main
func main() {
m := make(map[int]int, 3)
x := len(m)
m[1] = m[1]
y := len(m)
println(x, y)
}
Answer
Try it
0 1