fix: apply official errata (#672)

see documentation:
https://sites.google.com/site/thewaytogo2012/the-gopher/Errata.pdf

see also:
https://sites.google.com/site/thewaytogo2012/the-gopher
This commit is contained in:
marjune
2019-07-11 12:07:32 +08:00
committed by ᴊ. ᴄʜᴇɴ
parent d755ccc849
commit 243c87171f

View File

@@ -144,7 +144,7 @@ switch initialization {
这种形式可以非常优雅地进行条件判断: 这种形式可以非常优雅地进行条件判断:
```go ```go
switch result := calculate(); { switch result := calculate() {
case result < 0: case result < 0:
... ...
case result > 0: case result > 0:
@@ -157,7 +157,7 @@ switch result := calculate(); {
在下面这个代码片段中,变量 a 和 b 被平行初始化,然后作为判断条件: 在下面这个代码片段中,变量 a 和 b 被平行初始化,然后作为判断条件:
```go ```go
switch a, b := x[i], y[j]; { switch a, b := x[i], y[j] {
case a < b: t = -1 case a < b: t = -1
case a == b: t = 0 case a == b: t = 0
case a > b: t = 1 case a > b: t = 1