标签:cas lan block elf extension sel val cti ==
使用where语句之前必须在where之前有一个主语变量名
//基类A继承了SomeProtocol协议才能添加扩展
extension SomeProtocol where Self: A {
func showParamA() {
print(self.a)
}
}
let arr = [1, 2, 4, 5, 6]
for (index, value) in arr.enumerated() where value > 4 {
print(index, value)
}
let arr = [1, 2, 4, 5, 6]
for (index, value) in arr.enumerated() where value > 4 {
switch value {
case let a where a < 6:
print(index)
default:
print(value)
}
}
let str : String? = "hello"
if let value = str, value.count == 5 {
print(value)
}
guard let value = str, value.count == 5 else { return }
print(value)
标签:cas lan block elf extension sel val cti ==
原文地址:https://www.cnblogs.com/xujinzhong/p/12441921.html