
reference.language.category_methods_basics.html Maven / Gradle / Ivy
Methods
Defining category methods
A category method is identified by its category and its prototype, defined by its name and its accepted arguments.
A category method is defined by declaring, within a category definition, its prototype and optional return value, followed by the method statements.
The minimal prototype has the following form:
- In E dialect:
define methodName as method doing:
- In O dialect:
methodName() {}
- In M dialect:
def methodName():
A category method must be defined within a category definition, as follows:
Method names
A method name can be any valid identifier i.e. a word starting with a letter and followed by any number of letters or digits.
Method return types
A Prompto method can return any number of values.
If no value is returned, the return type is known as Void
type.
If exactly 1 value is returned, the return type can be specified. When not specified, it is inferred by Prompto.
Specifying the return type is done as follows:
- In E dialect:
define methodName as method returning Type doing:
- In O dialect:
Type method methodName() {}
- In M dialect:
def methodName() -> Type:
where Type
is the name of an existing type.
If more than one value is returned, the return type is Tuple
. This can be convenient for quick development
but should not be used for large scale applications, because Prompto does not infer the type of Tuple elements.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy