Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Integer#|

self | other → integer

Bitwise OR; each bit in the result is 1 if either corresponding bit in self or other is 1, 0 otherwise:

Example
"%04b" % (0b0101 | 0b0110) # => "0111"

Raises an exception if other is not an Integer.

Related: Integer#& (bitwise AND), Integer#^ (bitwise EXCLUSIVE OR).

See also #^ #~ #[] #abs also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0