[Top]
predef::
|
Method `+()
- Method
`+
-
mixed `+(mixed arg1)
mixed `+(object arg1, mixed ... extras)
string `+(string arg1, string|int|float arg2)
string `+(int|float arg1, string arg2)
int `+(int arg1, int arg2)
float `+(float arg1, int|float arg2)
float `+(int|float arg1, float arg2)
array `+(array arg1, array arg2)
mapping `+(mapping arg1, mapping arg2)
multiset `+(multiset arg1, multiset arg2)
mixed `+(mixed arg1, mixed arg2, mixed ... extras)
- Description
-
Addition operator.
- Returns
-
If there's only a single argument, that argument will be returned.
If arg1 is an object and it has an lfun::`+() ,
that function will be called with the rest of the arguments,
and the result returned.
Otherwise if any of the other arguments is an object that has
an lfun::``+() the first such function will be called
with the arguments leading up to it, and `+() be called recursively
with the result and the rest of the arguments.
If there are two arguments the result will be:
arg1 can have any of the following types:
string | arg2 will be converted to a string, and the result the
strings concatenated.
|
int|float | arg2 can have any of the following types:
string | arg1 will be converted to string, and the result the
strings concatenated.
|
int|float | The result will be arg1 + arg2 , and will
be a float if either arg1 or arg2 is a float.
|
|
|
array | The arrays will be concatenated.
|
mapping | The mappings will be joined.
|
multiset | The multisets will be added.
|
|
Otherwise if there are more than 2 arguments the result will be:
`+(`+(arg1 , arg2 ), @extras )
- Note
-
In Pike 7.0 and earlier the addition order was unspecified.
If arg1 is UNDEFINED it will behave as the empty
array/mapping/multiset if needed. This behaviour was new
in Pike 7.0.
- See also
-
`-() , lfun::`+() , lfun::``+()
|