1 //用if let與guard let實現同一效果,會發現guard下降一個分支 2 //能夠用if var guard var 表示定義的變量能修改值 3 func test(){ 4 let name:String? = "張三" 5 6 if let a = name { 7 print(a) 8 }else{ 9 print("李四") 10 } 11 12 guard let c = name else { 13 print("李四") 14 return 15 } 16 print("c=\(c)") 17 18 } 19 test()