Swift's if-case statement

Swift's if-case statement

I have found myself repeatedly writing if conditions to try match a specific range which can become unruly. Example: if let httpResponse = httpResponse where httpResponse > 200 && httpResponse < 300 { print("httpResponse is \(httpResponse)") } The more complex the ranges you are looking to capture the longer the conditions can become. That is where the if-case comes in handy. The above can be rewritten to: if let httpResponse = httpResponse, case 200...300 = httpResponse { print("httpResponse is \(httpResponse)") } Viola, no need to endlessly chain && ||