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.pod6
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ For example
67
67
68
68
dies with
69
69
70
-
Cannot modify an immutable Int
70
+
Cannot assign to an immutable value
71
71
72
72
in the first line marked with C<# WRONG>, because C<$.x>, short for C<$(
73
73
self.x )>, is a call to a read-only accessor.
@@ -236,7 +236,7 @@ than requiring every element to be checked on every call.
236
236
237
237
=head2Quotes and interpolation
238
238
239
-
Interpolation in string literals can be too clever for your good.
239
+
Interpolation in string literals can be too clever for your own good.
240
240
241
241
"$foo<html></html>" # Perl 6 understands that as:
242
242
$foo<html> ~ '</html>'
@@ -255,7 +255,7 @@ without using C<Q:c> as your quoting construct.
255
255
256
256
There are methods that Str inherits from Any that work on iterables like lists. Iterators on Strings contain one element that is the whole string. To use C<sort>, C<reverse> and friends, you need to split the string into a list first.
257
257
258
-
say "cba".sort; # OUTPUT: «cba» (what is wrong)
258
+
say "cba".sort; # OUTPUT: «(cba)» (what is wrong)
259
259
say "cba".comb.sort.join; # OUTPUT: «abc»
260
260
261
261
=head1Operators
@@ -272,25 +272,25 @@ bitwise operators in Perl 6 are: C<+^>, C<+|>, C<+&> for integers and C<?^>, C<
272
272
In some languages, using strings as range end points, considers the entire string when figuring out what the next string
273
273
should be; loosely treating the strings as numbers in a large base. Here's Perl 5 version:
274
274
275
-
say join ", ", "az".."bc"
275
+
say join ", ", "az".."bc";
276
276
az, ba, bb, bc
277
277
278
278
Such a range in Perl 6 will produce a different result, where I<each letter> will be ranged to a corresponding letter in the
279
279
end point, producing more complex sequences:
280
280
281
-
say join ", ", "az".."bc"'
281
+
say join ", ", "az".."bc";
282
282
az, ay, ax, aw, av, au, at, as, ar, aq, ap, ao, an, am, al, ak, aj, ai, ah,
283
283
ag, af, ae, ad, ac, bz, by, bx, bw, bv, bu, bt, bs, br, bq, bp, bo, bn, bm,
284
284
bl, bk, bj, bi, bh, bg, bf, be, bd, bc
285
285
286
-
say join ", ", "r2".."t3"
287
-
r2, r3, s2, s3, t2, t3
286
+
say join ", ", "r2".."t3";
287
+
# OUTPUT: «r2, r3, s2, s3, t2, t3»
288
288
289
289
To achieve simpler behaviour, similar to the Perl 5 example above, use a sequence operator that calls C<.succ> method on the
290
290
starting string:
291
291
292
-
say join ", ", ("az", *.succ ... "bc")
293
-
az, ba, bb, bc
292
+
say join ", ", ("az", *.succ ... "bc");
293
+
# OUTPUT: «az, ba, bb, bc»
294
294
295
295
=head2Topicalizing Operators
296
296
@@ -342,8 +342,8 @@ Adverbs do have a precedence that may not follow the order of operators that is
342
342
343
343
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.
344
344
345
-
1..3.say # says "3" (and warns about useless "..")
346
-
(1..3).say # says "1..3"
345
+
1..3.say; # says "3" (and warns about useless "..")
0 commit comments