Files
the-way-to-go_ZH_CN/eBook/18.3.md
songleo 830785f46e modified: eBook/18.10.md
modified:   eBook/18.3.md
	modified:   eBook/18.4.md
	modified:   eBook/18.5.md
	modified:   eBook/18.6.md
	modified:   eBook/18.7.md
	modified:   eBook/18.8.md
	modified:   eBook/18.9.md
2016-01-03 22:25:47 +08:00

29 lines
610 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 18.3 映射
创建: `map1 := make(map[keytype]valuetype)`
初始化: `map1 := map[string]int{"one": 1, "two": 2}`
1如何使用`for`或者`for-range`遍历一个映射:
```go
for key, value := range map1 {
}
```
2如何在一个映射中检测键`key1`是否存在:
`val1, isPresent = map1[key1]`
返回值:键`key1`对应的值或者`0`, `true`或者`false`
3如何在映射中删除一个键
`delete(map1, key1)`
## 链接
- [目录](directory.md)
- 上一节:[数组和切片](18.2.md)
- 下一节:[结构体](18.4.md)