Point = Struct.new(:x, :y) do
def to_string()
"x = #{x}; y = #{y}"
end
def move(right, down)
self.x += right
self.y += down
end
end
p1 = Point.new(1, 2)
str1 = p1.to_string()
# str1 is "x = 1; y = 2"
p1.move(5, -1)
str2 = p1.to_string()
# str2 is "x = 6; y = 1"
puts "str1 is '#{str1}'"
puts "str2 is '#{str2}'"