美文网首页
Go语言 - switch/case

Go语言 - switch/case

作者: louyang | 来源:发表于2018-01-12 15:26 被阅读5次
# cat switch.go
package main

import "fmt"

func main() {
    i := 2
    switch i {
    case 1:
        fmt.Println("one")
    case 2:
        fmt.Println("two")
    case 3:
        fmt.Println("three")
    }
}
# go run switch.go
two

参考
https://gobyexample.com/switch

相关文章

网友评论

      本文标题:Go语言 - switch/case

      本文链接:https://www.haomeiwen.com/subject/vwefoxtx.html