Skip to content

Commit

Permalink
Adds new Label stuff Raku#4043
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Mar 21, 2022
1 parent e349e63 commit ad6c0c6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions doc/Type/Label.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
class Label {}
Labels are used in Raku to tag loops so that you can specify
the one you want to jump to with L«statements such as
the specific one you want to jump to with L«statements such as
C<last>|/language/control#LABELs». You can use it to jump out of loops
and get to outer ones, instead of just exiting the current loop or going
to the statement before.
to the previous statement.
=begin code :skip-test<compile time error>
USERS: # the label
Expand All @@ -24,9 +24,9 @@ for @users -> $u {
say USERS.^name; # OUTPUT: «Label␤»
=end code
Those label are objects of type C<Label>, as shown in the last statement. Labels
can be used in any loop construct, as long as they appear right before the loop
statement.
Those labels are objects of type C<Label>, as shown in the last statement.
Labels can be used in any loop construct, as long as they appear right before
the loop statement.
=begin code
my $x = 0;
Expand Down Expand Up @@ -59,17 +59,24 @@ You can use, however, other alphabets like here:
=head2 method name
Defined as:
method name()
Not terribly useful, returns the name of the defined label:
A: while True {
say A.name; # OUTPUT: «A␤»
last A;
}
=head2 method file
Returns the file the label is defined in.
=head2 method line
Returns the line where the label has been defined.
=head2 method Str
Converts to a string including the name, file and line it's been defined in.
=head2 method next
Expand Down

0 comments on commit ad6c0c6

Please sign in to comment.