[DGD] & operato

Mikael Lind mikkelin at gmail.com
Tue Nov 6 08:50:33 CET 2007


On 06/11/2007, chris . <psych_mayo at hotmail.com> wrote:
>
>
> I saw an unfamiliar operator in the kernel lib...it went something like
> this:
> if(sizeof(query_users() & ({str}) ) == 0)
> I figure this translates something to effect of 'return to me the number
> of instances str appears in array returned by query_users()'
> Am i getting it?
>

Yes. The & operator means bitwise-and for int arguments and set-intersection
for arrays. The count of any element in the resulting array will be the
minimum of its counts in the two array arguments. In the code that you
quoted, the resulting array will contain at most one copy of str and nothing
else.

Mikael



More information about the DGD mailing list