mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:11:49 +08:00
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:
@@ -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
|
||||||
|
Reference in New Issue
Block a user