-
高级。。。。查看全部
-
import UIKit func getMaxAndMinFrom(arr: [Int]) -> (max: Int, min:Int)? { guard arr.count > 0 else { return nil } var maxNum = arr[0] var minNum = arr[0] for num in arr { maxNum = num > maxNum ? num : maxNum minNum = num < minNum ? num : minNum } return (maxNum, minNum) } var scores: [Int]? = [202, 1453, 45, 1230, 882, 10] scores = scores ?? [] var result = getMaxAndMinFrom(scores!) if let result = result { print("max of array is \(result.max)") print("min of array is \(result.min)") }查看全部
-
nil colase对optional 判断是否为nil 进行不同情况 执行不同操作查看全部
-
。。。。查看全部
-
errorMsg?.upperCaseString 尝试解包 errorMsg!.upperCaseString确定解包查看全部
-
解包 unwrap errorCode! 肯定知道是不空的 非nil.强制解包有风险 if errorCode!=nil{code+errorCode!} if let unwrapedErrorCOoe = errorCode{"code"+ unWrappedErroeCode} if let errorCode = errorCode{"code"+ errorCode} else{"no error}// errorCode只限在花括号中 if let errorCode =errorCode , errorMsg = erroeMsg{}//多个解包 if let errorCode =errorCode , errorMsg = erroeMsg where errorCode =="404"{}//多个解包 包含多个条件处理查看全部
-
这个地方高级..查看全部
-
这点猜到了查看全部
-
这个比OC强多了..查看全部
-
print 这个我好像以前知道 0 0查看全部
-
子集 ,超集.相离的.查看全部
-
亦或//查看全部
-
交集 . 减法查看全部
-
并集//查看全部
-
代替三目运算那个确实强大查看全部
举报
0/150
提交
取消