package main
import (
"fmt"
)
func main() {
//Output: 1 matches 1,2
testSwitch()
}
func testSwitch() {
a := 1
switch a {
// case 1:
// fmt.Println("1 matches 1,2") //.\test_switch.go:17:8: duplicate case 1 in switch
case 1,2:
fmt.Println("1 matches 1,2")
case 0,3:
fmt.Println("1 matches 1,3")
case 4:
fmt.Println("1 matches 1")
}
}
go switch case 同时匹配多个值 multi value in case
最新推荐文章于 2022-10-16 16:12:10 发布