From: Tom Werner Date: 2006-12-14T04:33:17+09:00 Subject: Re: How to overload the operator !=? ankyhe@gmail.com wrote: > I overload ==, >, <, >=, <=successfully, however I can't overload != . > How to overload operator !=? > > > > The != token is not really a method at all and thus cannot be redefined. It is, rather, syntactic sugar that calls == and negates the result. You can see for yourself that this is true: class Foo def ==(other) puts '== called' true end end f1 = Foo.new f2 = Foo.new f1 == f2 f1 != f2 Which outputs == called == called And upon reflection, this makes sense, as in any sane world !(f1 == f2) will equal (f1 != f2), and so redefining != would be redundant. Tom