Swift If (Logical Operators)
Swift If with Logical Operators
Combine conditions with &&, ||, and negate with !.
Combine conditions with logical operators
Use AND, OR, and NOT to build complex conditions that control code paths.
Example
let isMember = true
let hasCoupon = false
if isMember || hasCoupon {
print("Discount applied")
}
AND and NOT
Combine conditions with && and negate with !.
Example
let isMember = true
let expired = false
if isMember && !expired {
print("Active member")
}