Skip to content

Commit 587d0a3

Browse files
committed
Document class Label
1 parent 99ca399 commit 587d0a3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

lib/Type/Label.pod

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
=begin pod
2+
3+
=TITLE class Label
4+
5+
=SUBTITLE Labels for control operations such as C<next> and C<last>
6+
7+
class Label { ... }
8+
9+
In Perl 6, you can give for example loops a label, and use it to control that
10+
loop (instead of the inner-most loop).
11+
12+
USERS: # the label
13+
for @users -> $u {
14+
for $u.pets -> $pet {
15+
# usage of a label
16+
next USERS if $pet.barks;
17+
}
18+
say "None of {$u}'s pets barks";
19+
}
20+
say USERS.^name; # Label
21+
22+
Those label are objects of type C<Label>.
23+
24+
=head1 Methods
25+
26+
=head2 method next
27+
28+
method next(Label:)
29+
30+
Begin the next iteration of the loop assoicated with the label.
31+
32+
=head2 method last
33+
34+
method last(Label:)
35+
36+
Terminate the execution of the loop assoicated with the label.
37+
38+
=end pod

0 commit comments

Comments
 (0)