Method `|()
- Method
`|
mixed`|(mixedarg1)
mixed`|(mixedarg1,mixedarg2,mixed...extras)
mixed`|(objectarg1,mixedarg2)
mixed`|(mixedarg1,objectarg2)
int`|(intarg1,intarg2)
string`|(stringarg1,stringarg2)
array`|(arrayarg1,arrayarg2)
mapping`|(mappingarg1,mappingarg2)
multiset`|(multisetarg1,multisetarg2)
type`|(program|typearg1,program|typearg2)- Description
Bitwise or/union.
Every expression with the
|operator becomes a call to this function, i.e.a|bis the same aspredef::`|(a,b).- Returns
If there's a single argument, that argument is returned.
If there are more than two arguments, the result is:
`|(`|(.arg1,arg2), @extras)Otherwise, if
arg1is an object with an lfun::`|(), that function is called witharg2as argument, and its result is returned.Otherwise, if
arg2is an object with an lfun::``|(), that function is called witharg1as argument, and its result is returned.Otherwise the result depends on the argument types:
arg1can have any of the following types:intBitwise or of
arg1andarg2.zeroUNDEFINED may be or:ed with multisets, behaving as if it was an empty multiset.
stringThe result is a string where each character is the bitwise or of the characters in the same position in
arg1andarg2. The arguments must be strings of the same length.arrayThe result is an array with the elements in
arg1concatenated with those inarg2that doesn't occur inarg1(according to `>, `<, `==). The order between the elements that come from the same argument is kept.Every element in
arg1is only matched once against an element inarg2, so ifarg2contains several elements that are equal to each other and are more than their counterparts inarg1, the rightmost remaining elements inarg2are kept.mappingThe result is like
arg1but extended with the entries fromarg2. If the same index (according to hash_value and `==) occur in both, the value fromarg2is used.multisetThe result is like
arg1but extended with the entries inarg2that don't already occur inarg1(according to `>, `< and `==). Subsequences with orderwise equal entries (i.e. where `< returns false) are handled just like the array case above.type|programType union of
arg1andarg2.The function is not destructive on the arguments - the result is always a new instance.
- Note
If this operator is used with arrays or multisets containing objects which implement lfun::`==() but not lfun::`>() and lfun::`<(), the result will be undefined.
The treatment of UNDEFINED with multisets was new in Pike 8.1.
- See also