# Cannot override #== with mixin, was help with patch to ruby-

**URL:** <https://www.ruby-forum.com/t/cannot-override-with-mixin-was-help-with-patch-to-ruby/76700>\
**Category:** Ruby\
**Created:** [November 20, 2006, 3:46pm UTC](https://www.ruby-forum.com/t/cannot-override-with-mixin-was-help-with-patch-to-ruby/76700 "2006-11-20T15:46:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flatekmonkey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e8c25b/32.png) [@flatekmonkey](https://www.ruby-forum.com/u/flatekmonkey)\
**Post date:** [November 20, 2006, 3:46pm UTC](https://www.ruby-forum.com/t/cannot-override-with-mixin-was-help-with-patch-to-ruby/76700/1 "2006-11-20T15:46:03Z")

</div>

Hi all

I have sent a little patch, defining HalfOrder, to ruby-core in order to  
get  
some help with a problem I have found. Maybe this was not the best  
procedure.  
So I’ll try here again ☹

basically the patch defines a module HalfOrder which defines “\>”, “\>=”,  
“\<”  
and “==” depending on “\<=”, well almost because a potential #== in the  
Mixer  
class, as in Set cannot be overwritten. I think this is a shame.  
Here goes some code expressed in ruby instead of C

module HalfOrder

### Mixer has to define #\<=

…  
def == other

# in case of performance problems you might want to define ==

yourself  
self \<= other && other \<= self  
end  
…  
end

class Set  
include HalfOrder  
end

Set.new == Set.new # works while it should raise a NoMethodError for a  
missing #\<=

well _should_ as in I would like.

Any ideas? ( Maybe the HalfOrder module should complain or warn when  
mixed  
into a Class already containing a #==; guess I do not know how to do  
that in  
C, yet)

## Cheers Robert

The reasonable man adapts himself to the world; the unreasonable one  
persists in trying to adapt the world to himself. Therefore all progress  
depends on the unreasonable man.

- George Bernard Shaw
