Chapters

Hide chapters

Swift Cookbook

Live Edition · Multiplatform · Swift · Editor agnostic

Use Logical Operators in Swift
Written by Team Kodeco

Swift provides a set of basic logical operators that can be used to combine multiple conditions and create more complex statements. The basic logical operators in Swift are:

  • && for logical AND
  • || for logical OR
  • ! for logical NOT

Here’s an example of using logical operators in Swift:

let trueAndFalse = true && false // false
let trueOrFalse = true || false  // true
let notTrue = !true              // false
© 2024 Kodeco Inc.