Next: Conditional Operators

Prev: Arithmetic

Logic

C-- provides a number of relational and logical operators. These operators are primarily useful for expressing conditions, since they return either true or false, represented by the integers 1 and 0.

The == and != operators test for equality and inequality, respectively, of their arguments. Two pieces of data are equal if they have the same type and contain the same value. Equality of strings is not case-sensitive, but equality of symbols is, so ("foo" == "fOo") is true, but ('car == 'CAr) is false. Lists are equal if all of their elements are equal.

The <, <=, >=, and > operators test whether their left-hand arguments are less than, less than or equal to, greater than or equal to, or greater than their right-hand arguments, respectively. Arguments to these operators must both be of the same type, and must be of integer, string, or dbref type. String comparison is not case-sensitive, so ("fooa" < "fooB") is true, even though the ASCII value of a is greater than that of B.

The unary ! operator tests whether its argument is false, thus acting as a logical not operation.