[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to redefine != method?

Iñaki Baz Castillo

8/10/2008 11:53:00 PM

Hi, I can redefine =3D=3D method by doing:

def =3D=3D(string)

but it gives me an error if I try:

def !=3D(string)

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

How could I solve it?

Thanks a lot.


=2D-=20
I=C3=B1aki Baz Castillo

2 Answers

Dave Thomas

8/10/2008 11:59:00 PM

0


On Aug 10, 2008, at 6:53 PM, I=F1aki Baz Castillo wrote:

> Hi, I can redefine =3D=3D method by doing:
>
> def =3D=3D(string)
>
> but it gives me an error if I try:
>
> def !=3D(string)

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

Regards


Dave Thomas=

Iñaki Baz Castillo

8/11/2008 12:20:00 AM

0

El Lunes, 11 de Agosto de 2008, Dave Thomas escribi=F3:
> On Aug 10, 2008, at 6:53 PM, I=F1aki Baz Castillo wrote:
> > Hi, I can redefine =3D=3D method by doing:
> >
> > def =3D=3D(string)
> >
> > but it gives me an error if I try:
> >
> > def !=3D(string)
>
> !=3D is simply a negated call to =3D=3D, so defining =3D=3D also changes =
the
> definition of !=3D.

Great to know, thanks a lot.


=2D-=20
I=F1aki Baz Castillo