mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:55:35 +08:00
05.0.md
This commit is contained in:
22
eBook/examples/chapter_5/ifelse.go
Normal file
22
eBook/examples/chapter_5/ifelse.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
var first int = 10
|
||||
var cond int
|
||||
|
||||
if first <= 0 {
|
||||
fmt.Printf("first is less than or equal to 0\n")
|
||||
} else if first > 0 && first < 5 {
|
||||
fmt.Printf("first is between 0 and 5\n")
|
||||
} else {
|
||||
fmt.Printf("first is 5 or greater\n")
|
||||
}
|
||||
|
||||
if cond = 5; cond > 10 {
|
||||
fmt.Printf("cond is greater than 10\n")
|
||||
} else {
|
||||
fmt.Printf("cond is not greater than 10\n")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user