Foundation of Go Language —— 08. switch (Not translated)
»
    Go语言中也有switch-case语句块,它的每个case默认都会自动分隔开来,一个case执行完成后如果要继续执行下一个case的内容则需要使用fallthrough语句:
    var a = "hello"
    switch a {
    case "aaa":
        fmt.Println(11)
    case "hello":
        fmt.Println(1)
        fallthrough //继续下一 case
    case "world":
        fmt.Println(2)
    case "hello world","hello world1","hello world2"://多个case的相同处理
        fmt.Println(2)
    default:
        fmt.Println(0)
    }
    ————www.v-signon.com学习者共勉
                        
«
--Alex.Zhang
--www.v-signon.com Learningers Co-Encouraged
Back
Personal Art: www.up-task.com Unit: Individual
中文 Русский 京ICP备19038994号-2
If the content on this website infringes upon your any rights, please contact me at 1307776259@qq.com for removal