# Polymorphism

```ruby
class Point(x=0, y=0) {

}

class Circle(x=0, y=0, r=0) {

}

func pp(Point obj) {
    say "Point at #{obj.x},#{obj.y}"
}

func pp(Circle obj) {
    say "Circle at #{obj.x},#{obj.y} with radius #{obj.r}"
}
```

Example:

```ruby
pp(Point.new)               # => Point at 0,0
var p = Point(1, 2)         # create a point
pp(p)                       # => Point at 1,2
say p.x                     # => 1
p.y += 1                    # add one to y
pp(p)                       # => Point at 1,3

var c = Circle(4,5,6)       # create a circle
var d = c.clone             # make a clone of it
d.r = 7.5                   # and change the radius to 7.5
pp(c)                       # => Circle at 4,5 with radius 6
pp(d)                       # => Circle at 4,5 with radius 7.5
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/p/polymorphism.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
