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

Output:

hello, world

Example 2

Output:

I am sorry. I don't recognize you





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA