Use Logical Operators in Swift
Written by Team Kodeco
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
Prev chapter
2.
Use Comparison Operators in Swift
Next chapter
4.
Use Ternary Conditional Operator in Swift