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

go 的fallthrough特征

时间:2016-02-28 17:04:22      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:go

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 


本文出自 “dba天空” 博客,请务必保留此出处http://9425473.blog.51cto.com/9415473/1745730

go 的fallthrough特征

标签:go

原文地址:http://9425473.blog.51cto.com/9415473/1745730

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