3.3 If Statements

Statement if

  • () are optional, but {} are required
  • best practice → use () only with complex stmts
  • avoid 3+ levels of nested if stmts
// -> This is true
if (1 < 3) {
  print("This is true")
}

Statement if else

// -> This is true
if (1 < 3) {
  print("This is true")
} else if (1 < 2) {
  print("Yes, but not reached")
} else {
  print("Not true")
}