Dodo doc > Types > Constructors and Methods > Instance Methods
Methods are similar to functions with the addition that they can be overloaded to allow multiple argument lists. Methods build an object as their return value. While functions are generally stateless methods are generally stateful.
A method name follows the same syntax as a type name. It must start with an upper case letter and can contain letters, digits and underscore "_".
A method declaration starts with "method" followed by the method name, then a declaration block. Inside the declaration block, the method can have different bodies each with its own set of parameters.
A method body declaraction starts with the method name followed by the list of parameters, much in the same way as a constructor is declared (see section on constructors). In fact, a method declaration is exactly the same as a type declaration with constructors, a type which prototype is "method". A method does not have a default value.
There can be other declarations in the method declaration block which are accessed via the "self" variable inside a method body. Member variables can serve as the return values of the method.
method Mix: Mix(.Fruit, SpeedSetting?).
Play(Sound, .Output, Player.Options?)
Play(Video, .Window, Player.Options?)
A method invocation uses the dot to connect the object variable with the method name. The method name is followed by the list of arguments. An empty list of arguments is written with empty brackets.
A method can only be invoked on a variable reference. It can be a variable declared in the scope or an argument passed by reference. Methods cannot be used on constants.
To read the attributes of the object built by the method, the result of method invocation can be saved into a variable. This is a way to handle multiple return values.
def play = player.Play(mp3file, soundOut, [:low_latency, :simple_convol])