File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -152,15 +152,13 @@ the C<where>-clause inside the sub-signature.
152
152
153
153
= head3 Constraining Optional Arguments
154
154
155
- L < Optional arguments|Optional_and_Mandatory_Parameters > can have constraints, too.
156
- Here we want an optional UInt parameter that, if used, must be greater than 5:
155
+ L < Optional arguments|Optional_and_Mandatory_Parameters > can have constraints,
156
+ too. Any C < where > clause on any parameter will be executed, even if it's
157
+ optional and not provided by the caller. In that case you may have to guard
158
+ against undefined values whitin the C < where > clause.
157
159
158
160
sub f(Int $a, UInt $i? where { !$i.defined or $i > 5 } ) { ... }
159
161
160
- The signature may be made a bit simpler (but more obscure for the less expert eye) by using defaults:
161
-
162
- sub f(Int $a, UInt $i? where { !.defined or $_ > 5 } ) { ... }
163
-
164
162
= head3 Constraining Slurpy Arguments
165
163
166
164
L < Slurpy arguments|Slurpy_(A.K.A._Variadic)_Parameters > can not have type
You can’t perform that action at this time.
0 commit comments