作为map参考类型.有什么区别:?
m := make(map[string]int32)
Run Code Online (Sandbox Code Playgroud)
和
m := map[string]int32{}
Run Code Online (Sandbox Code Playgroud)
Lin*_*ope 103
一个允许您初始化容量,一个允许您初始化值:
// Initializes a map with space for 15 items before reallocation
m := make(map[string]int32, 15)
Run Code Online (Sandbox Code Playgroud)
VS
// Initializes a map with an entry relating the name "bob" to the number 5
m := map[string]int{"bob": 5}
Run Code Online (Sandbox Code Playgroud)
对于容量为0的空地图,它们是相同的,只是偏好.
| 归档时间: |
|
| 查看次数: |
55201 次 |
| 最近记录: |