If there's a single argument, that argument is returned.
If arg is an object with only one reference and an
lfun::`+=() , that function is called with the rest of the
arguments, and its result is returned.
Otherwise, if arg is an object with an lfun::`+() , that
function is called with the rest of the arguments, and its
result is returned.
Otherwise, if any of the other arguments is an object that has
an lfun::``+() , the first such function is called with the
arguments leading up to it, and `+() is then called
recursively with the result and the rest of the arguments.
Otherwise, if arg is UNDEFINED and the other arguments are
either arrays, mappings or multisets, the first argument is
ignored and the remaining are added together as described below.
This is useful primarily when appending to mapping values since
m[x] += ({foo})
will work even if m[x]
doesn't
exist yet.
Otherwise the result depends on the argument types:
int|float | The result is the sum of all the arguments. It's a float if
any argument is a float.
|
string|int|float | If any argument is a string, all will be converted to
strings and concatenated in order to form the result.
|
array | The array arguments are concatened in order to form the
result.
|
mapping | The result is like arg but extended with the entries from
the other arguments. If the same index (according to
hash_value and `== ) occur in several arguments, the
value from the last one is used.
|
multiset | The result is like arg but extended with the entries from
the other arguments. Subsequences with orderwise equal
indices (i.e. where `< returns false) are concatenated
into the result in argument order.
|
|
The function is not destructive on the arguments - the result is
always a new instance.