Q:

How to specify a range to avoid in Swift

I'm trying to make it so when I provide a value that isn't in the thirties it prints out a certain message. Here is my code:
let age = 25

if case 18...25 = age {
  print("Cool demographic")
}
else if case !(30...39) = age {
  print("not in there thirties")
}

A:

You can use pattern match operator ~= 
static func ~= (pattern: Range<Bound>, value: Bound) -> Bool

You can use this pattern matching operator (~=) to test whether a
  value is included in a range. The following example uses the ~=
  operator to test whether an integer is included in a range of
  numbers.

let age = 29

if 18...25 ~= age {
    print("Cool demographic")
} else if !(30...39 ~= age) {
    print("not in there thirties") // "not in there thirties\n"
}

