Syntax

The & operator syntax has these parts:

result = x & y

result =Any variableds
x =Any expression
y =Any expression.


The & operator looks at the binary representation of the values of two expressions and does a bitwise AND operation on them. The result of this operation behaves as follows:

0101 (x)
1100 (y)
----
0100 (result)

Any time both of the expressions have a 1 in a digit, the result has a 1 in that digit. Otherwise, the result has a 0 in that digit.

So, in the example given:

<tr bgcolor="@@((_index & 1) ? oddColor : evenColor )@@">

It takes the binary representation of the parameter '_index' and the binary representation of 1 and combines them according to the rules above. According to the rules of binary numbering, when index is odd, the result will be a 1, which in programming is equal to True, and therefore, the first argument (oddColor) will be used. If not, the even color will be used.