标签:style class blog code color com
在官方文档中,看到这句。但不明白什么意思。
let vegetable = "red pepper" switch vegetable { case "celery": let vegetableComment = "Add some raisins and make ants on a log" case "cocumber", "watercress": let vegetableComment = "That would make a good tea sandwich." case let x where x.hasSuffix("pepper"): let vegetableComment = "Is it a spicy \(x)?" default: let vegetableComment = "Everything tastes good in soup.123321" }
经过查资料,才发现这个是后缀的意思:
asPrefix:和hasSuffix:
前缀和后缀。
swift官方文档中的switch中case let x where x.hasSuffix("pepper")是什么意思?,布布扣,bubuko.com
swift官方文档中的switch中case let x where x.hasSuffix("pepper")是什么意思?
标签:style class blog code color com
原文地址:http://www.cnblogs.com/skiy/p/3805718.html