Rage Against The Machine* once covered a musing about smooth operators operating correctly.
Here we are going to cover overloading operators and getting them to operate as correctly and smoothly as possible.
What is operator overloading?
An operator is like a plus sign or a “greater than” sign. You typically think of them in expressions like
1 + 1 or
3 > 2. The operator operates on one or two operands. Most vanilla cases involve using numbers and the language already supports that. Even
String is somewhat supported:
val newString = "effec" + "t" // results in…