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)
mapping`&(mappingarg1,arrayarg2)
mapping`&(mappingarg1,multisetarg2)
multiset`&(multisetarg1,multisetarg2)
type`&(type|programarg1,type|programarg2)- Description
Bitwise and/intersection.
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 and of
arg1andarg2.stringThe result is a string where each character is the bitwise and of the characters in the same position in
arg1andarg2. The arguments must be strings of the same length.array|mapping|multisetThe result is like
arg1but only with the elements/indices that match any inarg2(according to `>, `<, `== and, in the case of mappings, hash_value).type|programType intersection 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.
- See also