Default parameter
If not provided, the default value is used.
Syntax
name(type p, [type q = default])
Description
Parameters inside square brackets are optional and can take default values. If not provided in the call, the default is used.
Example
Loading editor…
Expected output
Hello Alex Good morning Alex
When to use?
Arguments that are usually the same, but occasionally change.