Performs a bitwise OR on the value of a variable and the value of an expression and assigns the result to the variable.result |= expressionArguments resultAny variable.expressionAny expression.Res Using this operator is exactly the same as specifying: result = result | expression The |= operator looks at the binary representation of the values of result and expression and does a bitwise OR operation on them. The result of this operation behaves like this: 0101 (result) 1100 (expression) ---- 1101 (output) Any time either of the expressions has a 1 in a digit, the result has a 1 in that digit. Otherwise, the result has a 0 in that digit.
请参阅
| 运算符 | 运算符优先级 | 运算符总结
要求
版本 1
对变量值与表达式值执行按位“或”,并将结果赋给该变量。result |= expression
参数
result
任何变量。
expression
任何表达式。
说明
使用该运算符和使用下面的语句是等效的: result = result | expression
|= 运算符查看 result 和 expression 的二进制表示法的值,并执行按位“或”操作。该操作的结果如下所示: 0101 (result)
1100 (expression)
----
1101 (输出)
任何时候,只要两个表达式中的其中一个的某位是 1,则结果的该位是 1。否则,结果的该位是 0。
resultAny variable.expressionAny expression.Res
Using this operator is exactly the same as specifying: result = result | expression
The |= operator looks at the binary representation of the values of result and expression and does a bitwise OR operation on them. The result of this operation behaves like this: 0101 (result)
1100 (expression)
----
1101 (output)
Any time either of the expressions has a 1 in a digit, the result has a 1 in that digit. Otherwise, the result has a 0 in that digit.