Skip to content

Commit 15ce9aa

Browse files
committed
Adds examples for anon refs #1655
1 parent ffca8b2 commit 15ce9aa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/Language/variables.pod6

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,18 @@ but still aren't installed in a scope:
621621
say %operations<square>.name; # square
622622
say %operations<square>(8); # 64
623623
624+
Since it is a declarator, it can be applied anywhere anything is declared, for
625+
instance for classes or even sigilless variables.
626+
627+
say anon class þ {}; # OUTPUT: «(þ)␤»
628+
say anon sub þ { 42 }; # OUTPUT: «&þ␤»
629+
630+
Since these symbols are not installed in the scope, they can't be used by name.
631+
They are useful, however, if they need to be assigned to an external variable
632+
and they need to know their name themselves.
633+
634+
635+
624636
=head2 The C<state> declarator
625637
626638
C<state> declares lexically scoped variables, just like C<my>. However,

0 commit comments

Comments
 (0)