Function definition
Try it yourself →Defines your own command.
Syntax
ReturnType name(params) { return ...; }Description
Starts with the function return type (void = none), followed by name and parameters. return gives back the result. Binds repetitive work to a name.
Example
int square(int x) {
return x * x;
}
void main() {
print(square(5));
}Expected output
25
When to use?
Preventing code repetition, breaking the program into parts.