Swift-Switch穿透

switch vegetable {
        case "celery":
            print("Add some raisins and make ants on a log.")
        case "cucumber", "watercress":
            print("That would make a good tea sandwich.")
        case let x where x.hasSuffix("pepper"):
            print("Is it a spicy \(x)?")
            fallthrough
        case "red pepper":
            print("你妹啊")
        default:
            print("Everything tastes good in soup.")
        }
fallthrough所在的case中fallthrough后面的语句不在执行,直接执行下一个case,且下一个case判断语句要符合规则

posted on 2016-07-26 16:43  雨季的雾  阅读(1208)  评论(0编辑  收藏  举报