Dodo doc > Macros and Templates > Templates > Method Template


Method Template

To write a method template add the keyword "template" in front of the method name and add template parameters after it. The template parameters can be followed by a [where] clause to add parameter constraints.

The template applies to the whole method group. It is not possible to overload a method template with a plain method.

Example:

template (the: $Ingredient)
method Mix(&Ingredient[] food, SpeedSetting speed)
Rationale: A method declaration is equivalent to a type declaration with constructors, so the same rules apply.

^ 5.4.3. Type Template

v 5.4.5. Function Template