I’m new to ruby, and I saw this code snippet
1|2
and it returns 3
What does the | operator actually do? I couldn’t seem to find any documentation on it. Also, in this context is it referred to as the “pipe” operator? or is it called something else?
In Ruby, “operators” are actually method calls. They are defined by each class.
1 and 2 are Fixnum and so in
1|2pipe does “bitwise or”.Ruby doc
Bitwise info