mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
fix(05.1.md): add missing line separator (#641)
This commit is contained in:
@@ -167,20 +167,15 @@ func main() {
|
|||||||
var cond int
|
var cond int
|
||||||
|
|
||||||
if first <= 0 {
|
if first <= 0 {
|
||||||
|
|
||||||
fmt.Printf("first is less than or equal to 0\n")
|
fmt.Printf("first is less than or equal to 0\n")
|
||||||
} else if first > 0 && first < 5 {
|
} else if first > 0 && first < 5 {
|
||||||
|
|
||||||
fmt.Printf("first is between 0 and 5\n")
|
fmt.Printf("first is between 0 and 5\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
fmt.Printf("first is 5 or greater\n")
|
fmt.Printf("first is 5 or greater\n")
|
||||||
}
|
}
|
||||||
if cond = 5; cond > 10 {
|
if cond = 5; cond > 10 {
|
||||||
|
|
||||||
fmt.Printf("cond is greater than 10\n")
|
fmt.Printf("cond is greater than 10\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
fmt.Printf("cond is not greater than 10\n")
|
fmt.Printf("cond is not greater than 10\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +183,8 @@ func main() {
|
|||||||
|
|
||||||
输出:
|
输出:
|
||||||
|
|
||||||
first is 5 or greater cond is not greater than 10
|
first is 5 or greater
|
||||||
|
cond is not greater than 10
|
||||||
|
|
||||||
下面的代码片段展示了如何通过在初始化语句中获取函数 `process()` 的返回值,并在条件语句中作为判定条件来决定是否执行 if 结构中的代码:
|
下面的代码片段展示了如何通过在初始化语句中获取函数 `process()` 的返回值,并在条件语句中作为判定条件来决定是否执行 if 结构中的代码:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user