class Point
attr_accessor :x, :y
def initialize(x, y)
@x = x
@y = y
end
def ^(pow)
@x = @x ** pow
@y = @y ** pow
return self
end
end
p1 = Point.new(2, 3)
p1 = p1 ^ 3
# p1.x is 8 and p1.y is 27
p2 = Point.new(2, 3)
p2 ^ 2
# p2.x is 4 and p2.y is 9
puts "p1(x, y) is (#{p1.x}, #{p1.y})"
puts "p2(x, y) is (#{p2.x}, #{p2.y})"