Bitwise OR Operator
The bitwise OR operator (|
) is used to perform a bitwise OR operation on two numbers. This is not to be confused with the bitwise exclusive OR operator.
10 | 3 # => 11
> 10.to_s(2)
=> "1010"
> 3.to_s(2)
=> "11"
> (10 | 3).to_s(2)
=> "1011"
> 0b1011.to_i
=> 11
Note: this symbol is often generally referred to as the pipe symbol though it wouldn't make sense to call it that in this context.