四月三十号日报

package main

import "fmt"

func main() {
items := make([]map[int]int, 5)
for i := range items {
items[i] = make(map[int]int, 1)
items[i][i] = 2
}
fmt.Printf(" Value of items: %v\n", items)

items2 := make([]map[int]int, 5)
for _, item := range items2 {
	item = make(map[int]int, 1)//只是获得拷贝
	item[1] = 2
}
fmt.Printf(" Value of items: %v\n", items2)

}

posted on 2019-10-07 22:20  SWTCZB  阅读(102)  评论(0编辑  收藏  举报

导航