Method `==()


Method `==

bool `==(mixed arg1, mixed arg2, mixed ... extras)

Description

Equality test.

Every expression with the == operator becomes a call to this function, i.e. a==b is the same as predef::`==(a,b).

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 second argument is an object with an lfun::`==(), that function is called with the first as argument, and 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:

int

Successful iff the two integers are numerically equal.

float

Successful iff the two floats are numerically equal and not NaN.

string

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.)

array|mapping|multiset|object|function(:void)|program|type

Successful iff the two arguments point to the same instance.

Returns

Returns 1 if the test is successful, 0 otherwise.

Note

Floats and integers are not automatically converted to test against each other, so e.g. 0==0.0 is false.

Note

Programs are not automatically converted to types to be compared type-wise.

See also

`!(), `!=()