# Call an object method

```ruby
class MyClass {
    method foo(arg) { say arg }
}
 
var arg = 42
 
# Call a class method
MyClass.foo(arg)
 
# Alternatively, using an expression for the method name
MyClass.(:foo)(arg)
 
# Create an instance
var instance = MyClass()
 
# Instance method
instance.foo(arg)
 
# Alternatively, by using an expression for the method name
instance.(:foo)(arg)
 
# Alternatively, by asking for a method
instance.method(:foo)(arg)
```


---

# 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/c/call_an_object_method.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.
