Q:

Can I use the range operator in a guard statement in Swift?

I'm trying to figure out an alternate way to do something like this, using the range operator. 
guard let statusCode = (response as? HTTPURLResponse)?.statusCode, statusCode >= 200 && statusCode <= 299 else {return}

Maybe something like this:
guard let statusCode = (response as? HTTPURLResponse)?.statusCode where (200...299).contains(statusCode) else {return}

or 
guard let statusCode = (response as? HTTPURLResponse)?.statusCode, statusCode case 200...299 else {return}

Is this possible in Swift?

A:

As you like:
guard
    let statusCode = (response as? HTTPURLResponse)?.statusCode,
    (200...299).contains(statusCode) else {return}

or:
guard
    let statusCode = (response as? HTTPURLResponse)?.statusCode,
    case 200...299 = statusCode else {return}

or:
guard
    let statusCode = (response as? HTTPURLResponse)?.statusCode,
    200...299 ~= statusCode else {return}

A:

Here's a possibile solution
guard
    let statusCode = (response as? HTTPURLResponse)?.statusCode,
    200...299 ~= statusCode
    else { return }

