modified: eBook/18.1.md

modified:   eBook/18.11.md
	modified:   eBook/18.2.md
	modified:   eBook/18.3.md
	modified:   eBook/18.4.md
	modified:   eBook/18.8.md
This commit is contained in:
songleo
2016-01-03 14:29:25 +08:00
parent 34534d240c
commit 0aefb4a032
6 changed files with 52 additions and 61 deletions

View File

@@ -1,7 +1,7 @@
# 18.3 映射
创建: `map1 := make(map[keytype]valuetype)`
初始化: `map1 := map[string]int{"one": 1, "two": 2}`
创建: `map1 := make(map[keytype]valuetype)`
初始化: `map1 := map[string]int{"one": 1, "two": 2}`
1如何使用`for`或者`for-range`遍历一个映射:
@@ -13,13 +13,13 @@ for key, value := range map1 {
2如何在一个映射中检测键key1是否存在
`val1, isPresent = map1[key1]`
`val1, isPresent = map1[key1]`
返回值: 键`key1`对应的值或者`0`, `true`或者`false`
返回值: 键`key1`对应的值或者`0`, `true`或者`false`
3如何在映射中删除一个键
`delete(map1, key1)`
`delete(map1, key1)`
## 链接