fallthrough用于强制执行下一个case语句
package main
import "fmt"
func main() {
a := 4
switch a {
case 1:
fmt.Print("123")
case 2, 3, 4:
fmt.Print("456")
fallthrough
default:
fmt.Print("789")
}
}
输出456789
时间: 2024-10-18 20:47:30
fallthrough用于强制执行下一个case语句
package main
import "fmt"
func main() {
a := 4
switch a {
case 1:
fmt.Print("123")
case 2, 3, 4:
fmt.Print("456")
fallthrough
default:
fmt.Print("789")
}
}
输出456789