Swiftly

Swift 5.1 references for busy coders

If

If-else

if 5 > 6 {
  print("5 is more than 6")
} else {
  print("5 is not more than 6")
}
// Output: "5 is not more than 6"

Ternary conditional equivalent

5 > 6 ? print("5 is more than 6")
      : print("5 is not more than 6")
// Output: "5 is not more than 6"

See also