File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,21 @@ The first of those can be shortened to
139
139
i.e., you can use a literal directly as a type and value constraint
140
140
on an anonymous parameter.
141
141
142
+ B < Tip: > pay attention to not accidentally leave off a block when you,
143
+ say, have several conditions:
144
+
145
+ -> $y where .so && .name {}( sub foo {} ) # WRONG!!
146
+ -> $y where { .so && .name } {}( sub foo {} ) # OK!
147
+ -> $y where .so & .name.so {}( sub foo {} ) # Also good
148
+
149
+ The first version is wrong and will issue a warning about sub object coerced
150
+ to string. The reason is the expression is equivalent to
151
+ C < ($y ~~ ($y.so && $y.name)) > ; that is "call C < .so > , and if that is C < True > ,
152
+ call C < .name > ; if that is also C < True > use its value for smartmatching…". It's
153
+ the B < result > of C < (.so && .name) > is will be smartmatched against, but we
154
+ want to check that both C < .so > and C < .name > are truthy values. That is why
155
+ an explict Block or a L < Junction > is the right version.
156
+
142
157
All previous arguments that are not part of a sub-signature in a C < Signature >
143
158
are accessible in a C < where > -clause that follows an argument. Therefore,
144
159
the C < where > -clause of the last argument has access to all arguments of a
You can’t perform that action at this time.
0 commit comments