Swift关键字where

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_25639809/article/details/85007038

where : 用于条件判断

let point = (1, -1)  
switch point {  
case let (x, y) where x == y:  
    print("x == y")
case let (x, y) where x > y:  
    print("x > y")
case let (x, y) where x < y:  
    print("x < y")

猜你喜欢

转载自blog.csdn.net/qq_25639809/article/details/85007038