3 ms·
Operator overloading is good if the operator continues to mean the same thing across domains. If I have two integers and I want to add them together to create a
by ionforce 13y ago
Operator overloading is good if the operator continues to mean the same thing across domains. If I have two integers and I want to add them together to create a new integer, that's pretty clear. It's still clear that if I have two complex numbers or fractions that I would want to immutably add them up and create a new number. And so on with things like lists and sets, which as you pointed out are set operations.
I would be less inclined to extend this to domains that aren't about numbers or sets, like
genie + bottle
What exactly does that do?
It's kind of like implementing an interface. The implementation should do what it says on the box. In this case the box is the sign for addition.