class Point
attr_accessor :x, :y
def initialize(x, y)
@x, @y = x, y
end
def ==(other)
@x == other.x and
@y == other.y
end
end
p1 = Point.new(1, 1)
p2 = Point.new(2, 2)
p3 = Point.new(1, 1)
equal1 = p1 == p2
# equal1 is false
equal2 = p1 == p3
# equal2 is true
equal3 = p1 != p3
# equal3 is false
equal4 = p1 != p2
# equal4 is true
puts "equal1 is #{equal1}"
puts "equal2 is #{equal2}"
puts "equal3 is #{equal3}"
puts "equal4 is #{equal4}"