Перегрузка операторов

class Point
    attr_accessor :x, :y

    def initialize(x, y)
        @x, @y = x, y
    end

    def ~
        @x, @y = @y, @x
    end
  end

p = Point.new(13)
~p
# p.x is 3 and p.y is 1

puts "(x, y) is (#{p.x}#{p.y})"