Skip to content

Commit 8077cff

Browse files
committed
Merge pull request astaxie#342 from s7v7nislands/master
使代码符合go fmt输出
2 parents 52d9a6d + 1c50e70 commit 8077cff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ebook/02.2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ slice有一些简便的操作
386386
我们看下面的代码,`map`的读取和设置也类似`slice`一样,通过`key`来操作,只是`slice``index`只能是`int`类型,而`map`多了很多类型,可以是`int`,可以是`string`及所有完全定义了`==``!=`操作的类型。
387387

388388
// 声明一个key是字符串,值为int的字典,这种方式的声明需要在使用之前使用make初始化
389-
var numbers map[string] int
389+
var numbers map[string]int
390390
// 另一种map的声明方式
391391
numbers := make(map[string]int)
392392
numbers["one"] = 1 //赋值
@@ -410,7 +410,7 @@ slice有一些简便的操作
410410
通过`delete`删除`map`的元素:
411411

412412
// 初始化一个字典
413-
rating := map[string]float32 {"C":5, "Go":4.5, "Python":4.5, "C++":2 }
413+
rating := map[string]float32{"C":5, "Go":4.5, "Python":4.5, "C++":2 }
414414
// map有两个返回值,第二个返回值,如果不存在key,那么ok为false,如果存在ok为true
415415
csharpRating, ok := rating["C#"]
416416
if ok {

0 commit comments

Comments
 (0)