Comparison operators

Comparison operators are used to compare two values. The comparison operators are:

== equal to
!= not equal to
< less than
<= less than or equal to
> greater than
>= greater than or equal to

The following comparison rules apply:

  • scalar values (nil, boolean values, numbers and infinity) compare according to their numerical value;

  • strings and lists are greater than any scalar value;

  • lists compare sequentially according to their elements (keys are ignored);

  • functions are called with no arguments to get their value for comparison;

  • objects are equal only if they are the same.