Default parameter
If not provided, the default value is used.
Syntax
func name(p: Type = default)
Description
Parameters are given a default value using =. If omitted during a call, the default is used; this enables writing flexible functions.
Example
Loading editor…
Expected output
Hello Alex Good morning Alex
When to use?
Arguments that are usually the same, but occasionally change.