switch语句
a := 1
switch a {
case 1, 3:
fmt.Printf("a is 1 or 3\n")
case 2:
fmt.Printf("a is 2\n")
default:
fmt.Printf("default: a is %d\n", a)
}落空(fallthrough)
a := 1
switch a {
case 1:
fmt.Printf("case 1\n")
fallthrough
case 2:
fmt.Printf("caes 2\n")
}
// case 1
// caes 2字符串switch
空switch表达式
case的求值顺序
case的求值顺序switch语句中赋值
类型switch
最后更新于