i have an open source code and i need to understand what this operator " |= " do ?
thanks in advance
i have an open source code and i need to understand what this operator " |= " do ?
thanks in advance
It’s also a boolean or-equals operator.
For example:
myBool |= possiblyFalseBool;
is shorthand for:
myBool = myBool | possiblyFalseBool;
The logic here is that if myBool
is true, it prevents it from turning false in case possiblyFalseBool
actually is false.
The longer way to state it would be:
if (!myBool) {
myBool = possiblyFalseBool;
}