码迷,mamicode.com
首页 > 其他好文 > 详细

四月三十号日报

时间:2019-10-07 23:36:02      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:拷贝   imp   item   pac   range   package   map   func   print   

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)

}

四月三十号日报

标签:拷贝   imp   item   pac   range   package   map   func   print   

原文地址:https://www.cnblogs.com/swtczb/p/11632639.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!