Table of Contents

Comparison Operators compare two terms and return a Boolean.

Symbol | Type | Name | Description | Example |
---|---|---|---|---|

Equality Comparison | ||||

Standard comparison |
||||

== | Infix | Equal to | if both terms are equal `true` | ` a == b ` |

!= | Infix | Not equal to | if both terms are not equal `true` | ` a != b ` |

<> | Infix | Not equal to | if both terms are not equal `true` | ` a <> b ` |

=== | Infix | Identical to | if both terms are identical (equal, and of the same type) `true` | ` a === b ` |

!== | Infix | Not identical to | if both terms are not identical (are not equal, or are of different types) `true` | ` a !== b ` |

String comparison |
||||

eq | Infix | Equal to | if both terms are equal `true` | ` a eq b ` |

ne | Infix | Not equal to | if both terms are not equal `true` | ` a ne b ` |

Type checking |
||||

is | Infix | Is `type` | if the left term is of the type specified by the right term `true` | ` a is int ` |

Relational Comparison | ||||

Standard comparison |
||||

< | Infix | Less than | if the left term is less than the right term `true` | ` a < b ` |

<= | Infix | Less than or equal to | if the left term is less than or equal to the right term `true` | ` a <= b ` |

> | Infix | Greater than | if the left term is greater than the right term `true` | ` a > b ` |

>= | Infix | Greater than or equal to | if the left term is greater than or equal to the right term `true` | ` a >= b ` |

String comparison |
||||

lt | Infix | Less than | if the left term is less than the right term `true` | ` a lt b ` |

le | Infix | Less than or equal to | if the left term is less than or equal to the right term `true` | ` a le b ` |

gt | Infix | Greater than | if the left term is greater than the right term `true` | ` a gt b ` |

ge | Infix | Greater than or equal to | if the left term is greater than or equal to the right term `true` | ` a ge b ` |

Presence checking |
||||

in | Infix | Search | if the left term is found in the right term `true` | ` a in b ` |

Unlike most other Operators, Comparison Operators cannot be chained. So, whereas the expression `a + b + c`

is valid, `a < b < c`

will not have the desired effect. Instead, it should be written as `a < b && b < c`

.

Two sets of Comparison Operators are provided, with a standard set for normal checking, and an additional set for easy use of string comparison.

When using standard comparison, the left and right terms are compared as integer Numbers if at all possible, and as Strings otherwise. For instance, comparing "blue" and "red" would give ** false**, but comparing "+10" with "10.0" would give

`true`

`===`

and `!==`

), which do not try to convert value types.
When using the string comparison operators, terms are compared as Strings, according to the comparison directives in place. The string comparison operators are therefore safe for use when lazy comparison is undesirable, or when alternative behaviour is required (such as natural-order comparison, and case-insensitivity, both of which can be achieved by using the `Use`

command to change the comparison directives). However, comparison as Strings means that, for instance, `9`

will be greater than `10`

(just like `"b"`

is greater than `"ab"`

).

If necessary, the `compare()`

function can be used, as it allows the comparison method to be chosen on a per-call basis.