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.
--
Iñaki Baz Castillo
!= is simply a negated call to ==, so defining == also changes the definition of !=.
Regards
Dave Thomas
···
On Aug 10, 2008, at 6:53 PM, Iñaki Baz Castillo wrote:
Hi, I can redefine == method by doing:
def ==(string)
but it gives me an error if I try:
def !=(string)
Great to know, thanks a lot.
···
El Lunes, 11 de Agosto de 2008, Dave Thomas escribió:
On Aug 10, 2008, at 6:53 PM, Iñaki Baz Castillo 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 !=.
--
Iñaki Baz Castillo