码迷,mamicode.com
首页 > 其他好文 > 详细

Golang的fallthrough与switch的坑

时间:2017-06-06 18:30:16      阅读:182      评论:0      收藏:0      [点我收藏+]

标签: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的坑

标签:golang fallthrough switch 坑

原文地址:http://qiangmzsx.blog.51cto.com/2052549/1932845

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!