- Method `==
Every expression with the
==operator becomes a call to this function, i.e.
a==bis the same as
If more than two arguments are given, each argument is compared with the following one as described below, and the test is successful iff all comparisons are successful.
If the first argument is an object with an lfun::`==(), that function is called with the second as argument, unless the second argument is the same as the first argument. The test is successful iff its result is nonzero (according to `!).
Otherwise, if the arguments are of different types, the test is unsuccessful. Function pointers to programs are automatically converted to program pointers if necessary, though.
Otherwise the test depends on the type of the arguments:
Successful iff the two integers are numerically equal.
Successful iff the two floats are numerically equal and not NaN.
Successful iff the two strings are identical, character for character. (Since all strings are kept unique, this is actually a test whether the arguments point to the same string, and it therefore run in constant time.)
Successful iff the two arguments point to the same instance.
1if the test is successful,
Floats and integers are not automatically converted to test against each other, so e.g.
Programs are not automatically converted to types to be compared type-wise.
- See also