You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/Language/traps.pod
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -227,7 +227,9 @@ There are methods that Str inherits from Any that work on iterables like lists.
227
227
say "abc".reverse; # abc (what is wrong)
228
228
say "abc".comb.reverse.join; # cba
229
229
230
-
=head1Adverbs and Precedence
230
+
=head1Common Precedence Mistakes
231
+
232
+
=head2Adverbs and Precedence
231
233
232
234
Adverbs do have a precedence that may not follow the order of operators that is displayed on your screen. If two operators of equal precedence are followed by an adverb it will pick the first operator it find in the abstract syntax tree. Use paranteses to help Perl 6 to understand what you mean or use operators with looser precedence.
233
235
@@ -237,7 +239,14 @@ Adverbs do have a precedence that may not follow the order of operators that is
237
239
say !(%x<b>:exists); # works too
238
240
say not %x<b>:exists; # works as well
239
241
say True unless %x<b>:exists; # avoid negation altogether
240
-
242
+
243
+
=head2Ranges and Precedence
244
+
245
+
The loose precedence of C<..> can lead to some errors. It is usually best to parenthesize ranges when you want to operate on the entire range.
246
+
247
+
1..3.say # says "3" (and warns about useless "..")
0 commit comments