Can I use the range operator with if statement in Swift?

You can use the “pattern-match” operator ~=: if 200 … 299 ~= statusCode { print(“success”) } Or a switch-statement with an expression pattern (which uses the pattern-match operator internally): switch statusCode { case 200 … 299: print(“success”) default: print(“failure”) } Note that ..< denotes a range that omits the upper value, so you probably want … Read more