fallthrough语法

swift 中 switch case 后默认语句后面都会break, 所以当满足某个case之后仍旧想使它匹配下一个case,使用 fallthrough,则不会被截断;

case "b","B"
   print("this is b/B")
case "a":
   print("this is a")
   fallthrough
case let x where x.hasSuffix("peper"):
   print("has suffix " + x)
default:
   print("default")
}

你可能感兴趣的:(fallthrough语法)