Home > other >  The language switch statement
The language switch statement

Time:11-23

Use fallthrough can enforce the back of the case statement, fallthrough will not judge the next case expression result whether to true
Instance
Package the main

The import "FMT"

Func main () {

The switch {
Case false:
FMT. Println (" 1, case conditional statement is false ")
Fallthrough
Case true:
FMT. Println (" 2, case conditional statement is true ")
Fallthrough
Case false:
FMT. Println (" 3, case conditional statement is false ")
Fallthrough
Case true:
FMT. Println (" 4, case conditional statement is true ")
Case false:
FMT. Println (" 5, case conditional statement is false ")
Fallthrough
Default:
FMT. Println (" 6, the default case ")
}
}
  • Related