In Ruby, all things that are operators in C / Java, such as +, -, *, /, etc., are actually method calls. You can redefine them as you wish.
class MyInteger def +(other) 42 # or anything you want end end
Array defines a << method to denote "push this element at the end of this array." For integers, it is defined to shift bits.
In addition to Array, many other classes define << to represent any kind of "add" operation.
source share