Javatpoint Logo
Javatpoint Logo

Comparison Operators

Swift 4 supports all standard comparison operators of C language.

  • Equal to (a == b)
  • Not equal to (a != b)
  • Greater than (a > b)
  • Less than (a < b)
  • Greater than or equal to (a >= b)
  • Less than or equal to (a <= b)

Note: Swift 4 also provides two identity operators (=== and !==), which is used to test whether both object references refer to the same object instance.

Every comparison operator returns a Bool value to specify whether the statement is true or not.

Comparison operators are used in conditional statement as if statement.

Example 1


hello, world

Example 2


I am sorry. I don't recognize you

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA