Methods
A method is a distinct function defined for a specific type of object. There may be methods that share the same name, but each pointing at different functions, depending on the type of the object on which they are invoked.
The methods can also be invoked using the prefix notation:
The prefix and postfix notations can be used interchangeably:
A method can be invoked using the prefix notation, even when a function with the same name is declared in the same scope. This is done by preceding the method with ::
, as illustrated below:
Additionally, any alphanumeric method name can be used as an infix operator, by surrounding it with two backticks:
There is also support for calling a method which its name is not known until at run-time, which can be any expression that evaluates to a string:
If a method is not found for a given object, Sidef will throw a run-time error.
Last updated