How to redefine != method?

Hi, I can redefine == method by doing:

def ==(string)

but it gives me an error if I try:

def !=(string)


SyntaxError: compile error
(irb):2: syntax error, unexpected tNEQ
def !=(string); “hello” ; end
^
(irb):2: syntax error, unexpected kEND, expecting $end
from (irb):2

How could I solve it?

Thanks a lot.

On Aug 10, 2008, at 6:53 PM, Iñaki Baz C. wrote:

Hi, I can redefine == method by doing:

def ==(string)

but it gives me an error if I try:

def !=(string)

!= is simply a negated call to ==, so defining == also changes the
definition of !=.

Regards

Dave T.

El Lunes, 11 de Agosto de 2008, Dave T.
escribió:> definition of !=.
Great to know, thanks a lot.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs