Skip to content

Commit e361f83

Browse files
committed
Loop on undefined values, refs #2721
1 parent 9f9b350 commit e361f83

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

doc/Language/control.pod6

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ for it more strongly:
235235
$_ = 1; if 42 -> $a { $_.say; $a.say } ; # says "1" then says "42"
236236
$_ = 1; if 42 { $_.say; $^a.say } ; # says "1" then says "42"
237237
238-
=head2 X<else/elsif|control flow,else elsif>
238+
=head2 X<C<else/elsif>|control flow,else elsif>
239239
240240
A compound conditional may be produced by following an C<if> conditional
241241
with C<else> to provide an alternative block to run when the conditional
@@ -312,7 +312,7 @@ present:
312312
313313
if False { } elsif 0 { } else -> $a { $a.say } ; # says "0"
314314
315-
=head2 X<unless|control flow, unless>
315+
=head2 X<C<unless>|control flow, unless>
316316
317317
When you get sick of typing "if not (X)" you may use C<unless> to invert
318318
the sense of a conditional statement. You cannot use C<else> or C<elsif>
@@ -524,6 +524,17 @@ say "Not here" for Empty;
524524
Will not do anything. This constant is
525525
L<equivalent to a empty Slip or List|/syntax/Empty>.
526526
527+
Undefined values will behave in the same way:
528+
529+
=for code
530+
my @array := Empty;
531+
.say for @array;
532+
say @array; # OUTPUT: «()␤»
533+
534+
Assigning C<Empty> will effectively undefine an Array, using C<for> over an
535+
undefined array will not even enter the loop, as shown, effectively behaving in
536+
the same way as above when C<Empty> was used directly.
537+
527538
=head1 X<gather/take|control flow,gather take>
528539
529540
X<|lazy list,gather>X<|lazy list,take>

0 commit comments

Comments
 (0)