1. 程式人生 > >Golang的fallthrough與switch的坑

Golang的fallthrough與switch的坑

golang fallthrough switch 坑

最近寫Golang的是發現一個fallthrough與switch的坑:

switch value.(type) {
    case int:
        fallthrough
    case int64:
        //......
}

編譯就報錯:

cannot fallthrough in type switch

WHAT????

在type switch 中不能使用

fallthrough

只能修改代碼:

switch value.(type) {
    case int , int64:
        //......
}


本文出自 “夢朝思夕” 博客,請務必保留此出處http://qiangmzsx.blog.51cto.com/2052549/1932845

Golang的fallthrough與switch的坑