Skip to content

Commit 0c8fecf

Browse files
author
Jan-Olof Hendig
committed
Even more formatting fixes
1 parent e170c16 commit 0c8fecf

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

doc/Language/traps.pod6

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ method is automatically generated.
8080
Thus the correct way to write method C<double> is
8181
8282
=for code :skip-test
83-
method double {
84-
$!x *= 2;
85-
$!y *= 2;
86-
self;
87-
}
83+
method double {
84+
$!x *= 2;
85+
$!y *= 2;
86+
self;
87+
}
8888
8989
which operates on the attributes directly.
9090
@@ -116,17 +116,17 @@ since release 2016.11.
116116
One possible remedy is to explicitly initialize the attribute in C<BUILD>:
117117
118118
=for code :skip-test
119-
submethod BUILD(:$x) {
120-
$!y = 18;
121-
$!x := $x;
122-
}
119+
submethod BUILD(:$x) {
120+
$!y = 18;
121+
$!x := $x;
122+
}
123123
124124
which can be shortened to:
125125
126126
=for code :skip-test
127-
submethod BUILD(:$!x) {
128-
$!y = 18;
129-
}
127+
submethod BUILD(:$!x) {
128+
$!y = 18;
129+
}
130130
131131
Another, more general approach is to leave C<BUILD> alone, and hook into the
132132
C<BUILDALL> mechanism instead:
@@ -596,11 +596,11 @@ say %h.perl
596596
Sometimes you may need to match a generated string in a regex. The
597597
right way to do it is to use C<$(…)> or C«<{…}>» syntax.
598598
599-
=for code
600-
my $x = ‘ailemac’;
601-
say ‘I ♥ camelia’ ~~ / $($x.flip) /; # OUTPUT: «「camelia」␤»
602-
my $x = ‘ailemac’;
603-
say ‘I ♥ camelia’ ~~ / <{$x.flip}> /; # OUTPUT: «「camelia」␤»
599+
=for code
600+
my $x = ‘ailemac’;
601+
say ‘I ♥ camelia’ ~~ / $($x.flip) /; # OUTPUT: «「camelia」␤»
602+
my $x = ‘ailemac’;
603+
say ‘I ♥ camelia’ ~~ / <{$x.flip}> /; # OUTPUT: «「camelia」␤»
604604
605605
However, there is a wrong way to write it, and the problem is that
606606
it works I<sometimes>.
@@ -609,21 +609,21 @@ Internally C«<{…}>» EVAL-s the given string inside an anonymous regex, while
609609
C<$(…)> lexically interpolates the given string. So C«<{…}>» immediately breaks
610610
with more complicated inputs. For example:
611611
612-
=for code :skip-test
613-
my $x = ‘ailemac#’;
614-
say ‘I ♥ #camelia’ ~~ / $($x.flip) /; # OUTPUT: «「#camelia」␤»
615-
# ⚠ ↓↓ WRONG ↓↓ ⚠
616-
say ‘I ♥ camelia’ ~~ / <{$x.flip}> /; # OUTPUT: «「camelia」␤»
617-
# OUTPUT:
618-
# ===SORRY!===
619-
# Regex not terminated.
620-
# at EVAL_0:1
621-
# ------> anon regex { #camelia}⏏<EOL>
622-
# Malformed regex
623-
# at EVAL_0:1
624-
# ------> anon regex { #camelia}⏏<EOL>
625-
# expecting any of:
626-
# infix stopper
612+
=for code :skip-test
613+
my $x = ‘ailemac#’;
614+
say ‘I ♥ #camelia’ ~~ / $($x.flip) /; # OUTPUT: «「#camelia」␤»
615+
# ⚠ ↓↓ WRONG ↓↓ ⚠
616+
say ‘I ♥ camelia’ ~~ / <{$x.flip}> /; # OUTPUT: «「camelia」␤»
617+
# OUTPUT:
618+
# ===SORRY!===
619+
# Regex not terminated.
620+
# at EVAL_0:1
621+
# ------> anon regex { #camelia}⏏<EOL>
622+
# Malformed regex
623+
# at EVAL_0:1
624+
# ------> anon regex { #camelia}⏏<EOL>
625+
# expecting any of:
626+
# infix stopper
627627
628628
Therefore, try not to use C«<{}>» unless you really need EVAL.
629629
@@ -1007,9 +1007,9 @@ can await on. The solution is even more beautiful if you are
10071007
working in a L<react|/language/concurrency#index-entry-react> block:
10081008
10091009
=begin code :skip-test
1010-
whenever $proc.print: “one\ntwo\nthree\nfour” {
1011-
$proc.close-stdin;
1012-
}
1010+
whenever $proc.print: “one\ntwo\nthree\nfour” {
1011+
$proc.close-stdin;
1012+
}
10131013
=end code
10141014
10151015
=head2 Using <.stdout> without <.lines>
@@ -1259,7 +1259,7 @@ The right way to do it is to I<always> check that whatever you use in
12591259
your C<LEAVE> block is defined:
12601260
12611261
=begin code :skip-test
1262-
LEAVE say .Int with $x
1262+
LEAVE say .Int with $x
12631263
=end code
12641264
12651265
=head1 Unfortunate generalization

0 commit comments

Comments
 (0)