|=
I\'m curious to learn about this operator, I\'ve seen this notation used while setting flags in Java.
for example:
notification.flags |=
It is called bitwise or operator. For example,
5 = 0000 0101
2 = 0000 0010
5 | 2 = 0000 0111
= 14
So, this concept is used when a same option can use multiple values.
As an example, consider a variable flags equal to one.
int flags = 1;
Now, if a flag value of 4 is added to it with bitwise or,
flags |= 4; // 0
You can determine whether 4 was applied on flags with the bitwise and.
if (flags & 4 == 4) // returns true
If that flag has been applied on the flags, bitwise and returns flag. In this way we can use bitwise and & bitwise or.
Hope this helps.