Skip to content

Instantly share code, notes, and snippets.

@snowzurfer
Created March 7, 2023 06:08
Show Gist options
  • Save snowzurfer/f0a5a76ce2d9b595feffb7bb10cc2c86 to your computer and use it in GitHub Desktop.
Save snowzurfer/f0a5a76ce2d9b595feffb7bb10cc2c86 to your computer and use it in GitHub Desktop.
Check if a `HTTPURLResponse`'s `statusCode` is a 2xx
extension HTTPURLResponse {
/// Returns `true` if `statusCode` is in range 200...299.
/// Otherwise `false`.
var is2xx: Bool {
return 200 ... 299 ~= statusCode
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment