In ruby, what does |=
operator do?
Example:
a = 23
a |= 3333 # => 3351
|=
is called syntactic sugar.
In Ruby a = a | 3333
is the same as a |= 3333
.
|
means
Binary OR Operator copies a bit if it exists in either operand.Ruby Bitwise Operators
The single vertical bar is a bitwise OR operator.
a |= 3333
is equivalent to a = a | 3333