Swift Booleans

Swift Booleans

Bool represents logical true/false. Combine conditions with &&||, and negate with !.


Boolean Logic

Combine boolean values using logical AND (&&), OR (||), and negate with NOT (!).

Example

let a = true, b = false
print(a && b)
print(a || b)
print(!a)

This example shows logical AND, OR and NOT.



Comparison Results

Relational operators like >==, and != return Bool values that you can use in conditions.

Example

let a = 5, b = 3
print(a > b)   // true
print(a == b)  // false
print(a != b)  // true

Comparisons like >==, and != produce Bool values you can combine with logical operators.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *