On Mar 2, 2006, at 2:28 PM, Chris Parker wrote:

> Hi,
>
> I want to overload the != operator.  I can overload the ==  
> operator.  I
> get this error when I try to run the code without commenting out  
> the !=
> operator overloading function:
>
> CSP.rb:72: syntax error
>   def !=(other)
>
> The actual code is simply:
>
> def !=(other)
>
> end
>
> Does Ruby not allow overloading !=?  Does Ruby just give you != from
> ==?  This is a bit of a problem for my case because while != is the
> opposite of ==, there is a significant time improvement for  
> stopping as
> soon as possible for !=.
>
> Any help would be greatly appreciated.
>
> Chris
>
>

Is this fast enough?

def not_equal(other)
         # optimized != that stops early
end

def ==(other)
      not (not_equal(other))
end

so != gets turned into not (not (not_equal(other))) which is not  
perfect but the "nots" should be relatively trivial