In Kotlin, there are various comparison operators that can be used to compare values and produce Boolean results (“true” or “false”). Below are some of the most important comparison operators in Kotlin.
== equality operator: This operator is used to determine whether two values are equal.
The example above checks whether the value is from the variable a equal to the value of b is. Since they are not equal, the variable isEqual on false placed.
!= inequality operator: This operator is used to determine whether two values are not equal. For example:
This example checks whether the value of a not equal to the value of b is. Since they are unequal, the variable isNotEqual on true placed.
> Greater than operator: This operator is used to determine whether a value is greater than another value. For example:
This example checks whether the value of the variable a greater than the value of b is. Since this is the case, the variable isGreater on true placed.
< Less than operator: This operator is used to determine whether a value is less than another value. For example:
This example checks whether the value of a smaller than the value of b is. Since this is not the case, the variable isLess on false placed.
>= Greater than or equal operator: This operator is used to determine whether a value is greater than or equal to another value. For example:
This example checks whether the value of a greater than or equal to the value of b is. Since this is the case, the variable isGreaterOrEqual on true placed.
<= Less than or equal operator: This operator is used to determine whether a value is less than or equal to another value. For example:
This example checks whether the value of a less than or equal to the value of b is. Since this is the case, the variable isLessOrEqual on false placed.