Go Switch - Go 中使用 Switch 的六种方式
译者:baiyutang
原文:https://dev.to/eternaldev/go-switch-6-ways-of-using-switch-in-go-5a0l
基本
Switch case is commonly used there are multiple condition checks to be done for a particular variable. It is easier to understand than having multiple if statements in your code. Switch statement evaluates the expression and executes the block of code that matches from the list of possible choices
复制代码
带有 default 语句
复制代码
复制代码
case 列表
复制代码
fallthrough 语句
复制代码
break 语句
复制代码
版权声明: 本文为 InfoQ 作者【baiyutang】的原创文章。
原文链接:【http://xie.infoq.cn/article/38ccccd0d0ff989689484c146】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论