0Pricing
Swift Academy · Lesson

Logical Operators and Short-Circuiting

Combine conditions with &&, ||, ! and understand short-circuit evaluation.

Logical Operators

Logical operators combine Bool values: AND &&, OR ||, and NOT !. They are essential for building conditions.

let isWeekend = true
let isSunny = false
print(isWeekend && isSunny)
print(isWeekend || isSunny)
print(!isSunny)

Logical NOT

The ! operator flips a boolean: true becomes false and vice versa.

let loggedIn = false
if !loggedIn {
    print("Please log in")
}

All lessons in this course

  1. Arithmetic and Compound Assignment Operators
  2. Comparison and Identity Operators
  3. Logical Operators and Short-Circuiting
  4. Bitwise and Overflow Operators
← Back to Swift Academy