In object-oriented programming a method is a function associated with a particular class or object. In most forms of object oriented implementations methods can be static, associated with the class itself; or instance, associated with an instance of a class.

Show how to call a static or class method, and an instance method of a class.

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);