Skip to content

Commit 6f46c61

Browse files
committed
Update cookbook/01strings/01-00introduction.pl
The code: <code>my $string = "1" ~ "1" + 10;</code> will actually output "111" in Perl6. Since in Perl5, "~" (actually ".") is the same precedence as "+", but in Perl6, numeric operations have higher precedence. So the "1" + 1 part will be evaluated first, giving "111" as the result. Just a small modification here. :)
1 parent 30bb349 commit 6f46c61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cookbook/01strings/01-00introduction.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ =head1 Strings as numbers
164164
Context sensitivity is the essence of Perl. Keeping this in mind, what
165165
would you expect to be the output string, for the following?
166166
167-
my $string = "1" ~ "1" + 10; # 12 or 21?
167+
my $string = "1" ~ "1" + 10; # 12, 21, or even... "111"?
168168
say $string;
169169
170170
But, "1+1", surrounded by quotation marks, either '' or "", stringifies
@@ -185,7 +185,7 @@ =head1 Strings as numbers
185185
186186
=end pod
187187

188-
my $string = "1" ~ "1" + 10; # 12 or 21?
188+
my $string = "1" ~ "1" + 10; # 12, 21, or even... "111"?
189189
say $string;
190190
say "1 + 1"; # literally: 1 + 1
191191
say eval "1 + 1"; # 2

0 commit comments

Comments
 (0)