Extracted from Pike v7.3 release 16 at 2002-03-05.
pike.roxen.com
[Top]

Method `-()


Method `-

mixed `-(mixed arg1)
mixed `-(object arg1, mixed arg2)
mixed `-(mixed arg1, mixed arg2)
mapping `-(mapping arg1, array arg2)
mapping `-(mapping arg1, multiset arg2)
mapping `-(mapping arg1, mapping arg2)
array `-(array arg1, array arg2)
multiset `-(multiset arg1, multiset arg2)
float `-(float arg1, int|float arg2)
float `-(int arg1, float arg2)
int `-(int arg1, int arg2)
string `-(string arg1, string arg2)
mixed `-(mixed arg1, mixed arg2, mixed ... extras)

Description

Negation/subtraction operator.

Returns

If there's only a single argument, that argument will be returned negated. If arg1 was an object,

arg1::`-()
will be called without arguments.

If there are more than two arguments the result will be:

`-(`-(arg1, arg2), @extras)
.

If arg1 is an object that overloads `-(), that function will be called with arg2 as the single argument.

If arg2 is an object that overloads ``-(), that function will be called with arg1 as the single argument.

Otherwise the result will be as follows:

arg1 can have any of the following types:
mappingarg2 can have any of the following types:
array

The result will be arg1 with all occurrances of arg2 removed.

multiset

The result will be arg1 with all occurrences of

indices(arg2)
removed.


array

The result will be the elements of arg1 that are not in arg2.

float

The result will be

arg1 - arg2
, and will be a float if either arg1 or arg2 is a float.

string

Result will be the string arg1 with all occurrances of the substring arg2 removed.


Note

In Pike 7.0 and earlier the subtraction order was unspecified.

See also

`+