Java Operator: |= -
this question has answer here:
- what “|=” mean? (pipe equal operator) 6 answers
- java |= operator question [duplicate] 5 answers
i came across following line inside sourcecode.
int sequ |= element.sequence
what operator |= mean ? haven't seen before.
=|
compound assignment operator, similar +=
, -=
, /=
, or *=
, bitwise or instead.
this equivalent to:
sequ = (int) (sequ | element.sequence);
where |
bitwise or operation, meaning independently ors bits in left operand in right operand, result. cast not necessary if element.sequence
int
.
note: original code wouldn't make sense:
int sequ |= element.sequence
you can't declare there , , or else. need have been declared , assigned before, such in:
int sequ = 0; /* or other value */ sequ |= element.sequence;
Comments
Post a Comment