I am trying to override the ==
operation as shown here. I created ==
as so:
class Point
def ==(g)
p'Never reaches here'
if @x==g.grid
true
else
false
end
end
end
I am calling the method as so:
def home? (gridPoint,point)
if point==gridPoint
do something
end
When I run an application, "Never reaches here"
is never printed, and the application skips the rest of the code and exits.
If I print gridPoint
and Point
right before the ==
, I can see they are both points. Why does the program seem to have never entered the ==
method?
I tried point.==(gridPoint)
. This does not work either, and also defies the purpose of trying to clean the code.
Can anyone help me?