bool :eq ( mixed $ARG , … )
bool :== ( mixed $ARG , … )
Takes any number of arguments and checks for their equality. Performs a comparison between the rightmost pair of elements, then the second-rightmost, et cetera.
Returns TRUE
if all comparisons are deemed true, or FALSE
if any of the comparisons is deemed false.
The table below contains rules for comparing values. Note that these rules are often non-symmetrical; swapping the values may yield a different result. The row contains the type of the first (left) value in pair, while the column contains the type of the second (right) value in pair.
NIL | bool | bin | oct | int | hex | float | string | array | dict | |
---|---|---|---|---|---|---|---|---|---|---|
NIL | Always TRUE | Always FALSE | ||||||||
bool | Always FALSE | TRUE if values are equal. | If number is non-zero, it is treated as TRUE. This value is then compared with the boolean. | If absolute value of number is greater-or-equal to 1.0, it is treated as TRUE. This value is then compared with the boolean. | If string is true or contains a non-zero number, it is treated as TRUE. This value is then compared with the boolean. | Always FALSE | ||||
bin | Always FALSE | If bool is TRUE, it is converted to 1, or 0 otherwise. This value is then compared with the number. | TRUE if values are equal. | Float is truncated and then compared with the number. | String is converted to number (with regard to base). This value is then compared with the number. | Always FALSE | ||||
oct | ||||||||||
int | ||||||||||
hex | ||||||||||
float | Always FALSE | Float value is truncated and an int-like comparison is performed. | Float is truncated and then compared with the integer. | TRUE if values are equal. | String is converted to float, and this value is then checked for equality. | Always FALSE | ||||
string | Always FALSE | If string is true or contains a non-zero number, it is treated as TRUE. This value is then compared with the boolean. | String is converted to number (with regard to base). This value is then compared with the number. | String is converted to float, and this value is then checked for equality. | TRUE if strings are equal. | Always FALSE | ||||
array | Always FALSE | Always FALSE | Always FALSE | Always FALSE | Always FALSE | Always FALSE | ||||
dict |
# :eq example. :set &STR s'123' :set &NUM i123 :writeln s'STR and NUM are ' (:fork (:eq $STR $NUM) s'equal' s'unequal') s' (loose).' :writeln s'STR and NUM are ' (:fork (:seq $STR $NUM) s'equal' s'unequal') s' (strict).'
wikipage modified on 2014/0601/2317