我正试图找出另一种方法来做这样的事情,使用范围运算符.
@H_301_16@
随你心意:
guard let statusCode = (response as? HTTPURLResponse)?.statusCode,statusCode >= 200 && statusCode <= 299 else {return}
也许是这样的:
guard let statusCode = (response as? HTTPURLResponse)?.statusCode where (200...299).contains(statusCode) else {return}
要么
guard let statusCode = (response as? HTTPURLResponse)?.statusCode,statusCode case 200...299 else {return}
这在Swift中可能吗?
guard let statusCode = (response as? HTTPURLResponse)?.statusCode,(200...299).contains(statusCode) else {return}
要么:
guard let statusCode = (response as? HTTPURLResponse)?.statusCode,case 200...299 = statusCode else {return}
要么:
guard let statusCode = (response as? HTTPURLResponse)?.statusCode,200...299 ~= statusCode else {return}