Skip to content

Commit 42ab7a8

Browse files
committed
Changes wrong description
This closes 3075
1 parent 08721e5 commit 42ab7a8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

doc/Language/5to6-nutshell.pod6

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,13 @@ for my $car (@cars) {...} # Perl 5; read-write
872872
for @cars -> $car {...} # Raku; read-only
873873
for @cars <-> $car {...} # Raku; read-write
874874
875-
If the default topic C<$_> is being used, it is also read-write.
875+
In Raku and unlike Perl, the default topic C<$_> will behave in the same way,
876+
becoming read-only when used as a topic variable.
876877
877878
=for code :lang<perl5>
878879
for (@cars) {...} # Perl 5; $_ is read-write
879880
=for code :preamble<no strict;>
880-
for @cars {...} # Raku; $_ is read-write
881+
for @cars {...} # Raku; $_ is read-only
881882
for @cars <-> $_ {...} # Raku; $_ is also read-write
882883
883884
It is possible to consume more than one element of the list in each iteration

doc/Language/control.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,8 @@ for @foo <-> $value {
579579
say @bar; # # OUTPUT: «[Odd Even Odd]»
580580
=end code
581581
582-
By default the topic variable C«$_» is a read-write alias. Thus, if you want
583-
to use it as a read-only alias you must indicate it by using C«->».
582+
This rule also applies to the topic variable C«$_», which by default is a
583+
read-write alias; it will become read-only if it's used in a C«->» loop.
584584
585585
my @foo = 1..3;
586586
for @foo -> $_ { $_.say }

0 commit comments

Comments
 (0)