I noticed that Addable is deprecated, while Subtractable is not. What\'s wrong with Addable
, and why is Subtractable
different?
Expanding on Daniel's answer, +
is also a very bad operator to use for collection insertion. Mathematically, the +
operator has a very conventional meaning, and part of that meaning is a guarantee of associativity. Unfortunately, associativity is a guarantee that doesn't make any sense at all when you're adding an Int
to a Vector[Int]
. As such, +
was always a very confusing operator for anyone who had any algebraic training.
+:
and :+
are superior in several ways, not the least of which is that there is no expectation of associativity. In fact, the very asymmetry of the operators imply non-associativity, which is precisely their semantics. Also +:
and :+
mirror each-other very nicely, and +:
is right-associative, all of which conspires to provide a very natural API for collection prepend and append, respectively.