- Mastering macOS Programming
- Stuart Grimshaw
- 56字
- 2025-04-04 19:10:24
Comparison operators
Swift's comparison operators are also derived from C; the reader will doubtless recognize them immediately:
if x == 0 {print("x is equal to zero")}
if x != 0 {print("x is not equal to zero")}
if x < 0 {print("x is less than zero")}
if x > 0 {print("x is more than zero")}
if x <= 0 {print("x is less than or equal to zero")}
if x >= 0 {print("x is more than or equal to zero")}