Thanks for the replies everyone.
It is helpful but kind of disappointing. I’ll explain more about my
problem and maybe there is some clean solution.
So I am trying to write a new language on top of Ruby (without writing
any C) for Constraint Satisfaction Problems.
X1 == X2, which X1 is of class CSPVar will return a CSPConstraint that
contains the information about that constraint. Obviously, I need to
overload != because returning something like true or false makes no
sense. I am using != needs to return a CSPConstraint object reflecting
the information about the constraint, not true or false. After I have
all of the variables, domains, and constraints, I then solve the
The obvious but incredibly ugly solution is something like: X1.ne(X2).
Since I got ==, +, -, *, / all working like operators, it would be nice
to get != to work as well.
Let me know if you have any ideas. Also, I am really struggling to
understand why != can’t be overloaded. I understand providing a
default != which is just not(==), but completely not allowing the
overloading of != seems strange.