Skip to content

Commit 7677169

Browse files
authored
Merge pull request #3066 from uzluisf/master
Wrap inline code examples with C<>, remove unneeded capitalization, ...
2 parents 15132f7 + 6d0adfb commit 7677169

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

doc/Language/5to6-nutshell.pod6

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ how identifiers are defined.
6969
=head2 Identifiers
7070
7171
Raku allows the use of dashes (C<->), underscores (C<_>),
72-
apostrophes (C<'>), and alphanumerics in identifiers, :
72+
apostrophes (C<'>), and alphanumerics in identifiers:
7373
7474
sub test-doesn't-hang { ... }
7575
my $ความสงบ = 42;
@@ -223,8 +223,8 @@ name.
223223
The C<$> sigil is now always used with "scalar" variables (e.g. C<$name>),
224224
and no longer for L<array indexing|#[]_Array_indexing/slicing> and L<Hash
225225
indexing|#{}_Hash_indexing/slicing>. That is, you can still use C<$x[1]>
226-
and C<$x{"foo"}>, but it will act on $x, with no effect on a similarly
227-
named @x or %x. Those would now be accessed with @x[1] and %x{"foo"}.
226+
and C<$x{"foo"}>, but it will act on C<$x>, with no effect on a similarly
227+
named C<@x> or C<%x>. Those would now be accessed with C<@x[1]> and C<%x{"foo"}>.
228228
229229
=head3 C<@> Array
230230
@@ -465,8 +465,8 @@ my @array = 4,8,15;
465465
say @array; # OUTPUT: «[66 8 15]␤»
466466
=end code
467467
468-
The underlying Array object of C<@array> is passed, and its first value modified
469-
inside the declared routine.
468+
The underlying C<Array> object of C<@array> is passed, and its first value
469+
modified inside the declared routine.
470470
471471
In Perl 5, the syntax for dereferencing an entire reference is the type-sigil
472472
and curly braces, with the reference inside the curly braces. In Raku, this
@@ -546,7 +546,7 @@ my @all_numbers = |@numbers, 400, |@more_numbers;
546546
That way one can concatenate arrays.
547547
548548
Note that one does not need to have any parentheses on the right-hand side:
549-
the List Separator takes care of creating the list, B<not> the parentheses!
549+
the list separator takes care of creating the list, B<not> the parentheses!
550550
551551
=head2 C«<=> cmp» Three-way comparisons
552552
@@ -677,13 +677,13 @@ $food = 'grape' ~ 'fruit'; # Raku
677677
678678
=head2 C<x> List repetition or string repetition operator
679679
680-
In Perl 5, C<x> is the Repetition operator, which behaves differently in
680+
In Perl 5, C<x> is the repetition operator, which behaves differently in
681681
scalar or list contexts:
682682
=item in scalar context C<x> repeats a string;
683683
=item in list context C<x> repeats a list, but only if the left argument
684684
is parenthesized!
685685
686-
Raku uses two different Repetition operators to achieve the above:
686+
Raku uses two different repetition operators to achieve the above:
687687
=item C<x> for string repetitions (in any context);
688688
=item C<xx> for list repetitions (in any context).
689689
@@ -745,7 +745,7 @@ it does not allow for an C<elsif> or C<else> clause.
745745
=head3 C<given>-C<when>
746746
747747
The C<given>-C<when> construct is like a chain of C<if>-C<elsif>-C<else>
748-
statements or like the C<switch>-C<case> construct in e.g. C. It has the
748+
statements or like the C<switch>-C<case> construct C, for example. It has the
749749
general structure:
750750
751751
=for code :lang<pseudo>
@@ -880,8 +880,8 @@ for (@cars) {...} # Perl 5; $_ is read-write
880880
for @cars {...} # Raku; $_ is read-write
881881
for @cars <-> $_ {...} # Raku; $_ is also read-write
882882
883-
It is possible to consume more than one element of the list in each iteration simply specifying
884-
more than one variable after the arrow operator:
883+
It is possible to consume more than one element of the list in each iteration
884+
simply specifying more than one variable after the arrow operator:
885885
886886
=begin code
887887
my @array = 1..10;
@@ -890,6 +890,17 @@ for @array -> $first, $second {
890890
}
891891
=end code
892892
893+
For cases in which the number of elements iterated over isn't a multiple
894+
of the number of variables after the arrow operator, you can provide variables
895+
with default values:
896+
897+
=begin code
898+
my @array = 1..9;
899+
for @array -> $first, $second = 0 {
900+
say "First is $first, second is $second";
901+
}
902+
=end code
903+
893904
=head4 C<each>
894905
895906
Here is the equivalent to Perl 5’s C<while…each(%hash)> or C<while…each(@array)>

0 commit comments

Comments
 (0)