Gallery
Mochaccino
Share
Explore

icon picker
Functions

A function is declared using the func keyword:
func funcName(params)<type> {}

Function Signature

The part of the function that comes before the curly braces is known as the function signature, as it contains vital information about the function, such as its name, parameter types, return type, and whether it is async. The function signature is used when defining abstract methods in structs.

Parameters

Required Positional

Required Named

Optional Named


Return Type

The default return type is void, though it’s better to define it explicitly. Asynchronous functions must return a promise, with the type argument being the type that the promise resolves to.
func asyncMapGen()<promise<map>> async {
return {};
}
Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.