运算符重载

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

    def >(other)
        @x > other.x and 
        @y > other.y
    end
end

p1 = Point.new(12)
p2 = Point.new(23)

b1 = p1 > p2
# b1 is false
b2 = p1 < p2
# b2 is true

puts "b1 is #{b1}"
puts "b2 is #{b2}"