func (function)
Defines your own command.
Syntax
func name(_ p: Type) -> ReturnType { return ... }Description
Defined with func; -> specifies the return type. The _ before a parameter omits its label. return gives back the result.
Example
Loading editor…
Expected output
25
When to use?
Preventing code repetition, breaking the program into parts.