# Inequality test

**URL:** <https://www.ruby-forum.com/t/inequality-test/156084>\
**Category:** Ruby\
**Created:** [December 20, 2008, 7:16am UTC](https://www.ruby-forum.com/t/inequality-test/156084 "2008-12-20T07:16:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![enjo20](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c37758/32.png) [@enjo20](https://www.ruby-forum.com/u/enjo20)\
**Post date:** [December 20, 2008, 7:16am UTC](https://www.ruby-forum.com/t/inequality-test/156084/1 "2008-12-20T07:16:03Z")

</div>

Hi, all

I have tested comparison test by using object concept.

I mean this one

a = 1

a.send(’==’, 1)  
=\> true

a.send(’\>’, 0)  
==\>true

a.send(’\<’, -1)  
==\> false

With this concept, however, I cannot test inequlity test(’!=’).

Whenever I try to this test, I met the following error.

irb(main):001:0\> a = 1  
=\> 1  
irb(main):002:0\> a.send(’!=’, 0)  
NoMethodError: undefined method `!=' for 1:Fixnum from (irb):2:in`send’  
from (irb):2  
from :0  
irb(main):003:0\>

Any idea for this?

---

<div class="post-metadata">

**Author:** ![enjo20](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c37758/32.png) [@enjo20](https://www.ruby-forum.com/u/enjo20)\
**Post date:** [December 20, 2008, 7:26am UTC](https://www.ruby-forum.com/t/inequality-test/156084/2 "2008-12-20T07:26:35Z")

</div>

On Dec 20, 2008, at 07:07, juneng wrote:

> irb(main):002:0\> a.send(’!=’, 0)  
> NoMethodError: undefined method `!=' for 1:Fixnum from (irb):2:in`send’  
> from (irb):2  
> from :0

!= is purely syntactical sugar for !(foo == bar). If you send ‘==’ and  
negate the result, that’ll give you what you want. You can’t define  
the != method, and you can’t make it mean anything other than “the  
negation of ==.”
