Skip to content

Commit 9d392d1

Browse files
committed
Tweak Repetition operator.
For coherence with the perlop Perl 5 documentation all references have been adjusted to 'Repetition'. I've split the reminder of how Perl 5 'x' worked in string and list context and then presented the same items for Perl 6 'x' and 'xx'.
1 parent 8cf921a commit 9d392d1

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

doc/Language/5to6-nutshell.pod6

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,17 +718,19 @@ Mnemonic: think of "stitching" together the two strings with needle and thread.
718718
=for code :preamble<no strict;>
719719
$food = 'grape' ~ 'fruit'; # Perl 6
720720
721-
=head2 C<x> List Repeat op or String Repeat op
721+
=head2 C<x> List Repetition or String Repetition operator
722722
723-
In Perl 5, C<x> was the Repetition operator.
723+
In Perl 5, C<x> is the Repetition operator, which behaves differently in
724+
scalar or list contexts:
725+
=item in scalar context C<x> repeats a string;
726+
=item in list context C<x> repeats a list, but only if the left argument
727+
is parenthesized!
724728
725-
In scalar context, C<x> would repeat a string. In Perl 6, C<x> repeats
726-
strings in any context.
729+
Perl 6 uses two different Repetition operators to achieve the above:
730+
=item C<x> for string repetitions (in any context);
731+
=item C<xx> for list repetitions (in any context).
727732
728-
In list context, C<x> would repeat a list—but only if the left argument
729-
is parenthesized! In Perl 6, the new C<xx> op repeats lists in any context.
730-
731-
Mnemonic: x is short and xx is long, so xx is the one used for lists.
733+
Mnemonic: C<x> is short and C<xx> is long, so C<xx> is the one used for lists.
732734
733735
=for code :lang<perl5>
734736
# Perl 5

0 commit comments

Comments
 (0)