Browse files

[variables] document the ! twigil

  • Loading branch information...
1 parent cce60ee commit 6f41c1beb9460a8aca874a1bc1a35d44a3a23cc2 @felher felher committed Aug 29, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/variables.pod
@@ -100,6 +100,26 @@ C<$*dynamic1> isn't 11 anymore, but C<$*dynamic2> is still 101. This stems from
the fact that we declared a new dynamic variable C<$*dynamic1> in the block and
did not assign to the old variable as we did with C<$*dynamic2>.
+=head2 !
+Attributes are variables that exists per instance of a class. They may be
+directly accessed from within the class via C<!>:
+ class Point {
+ has $.x;
+ has $.y;
+ method Str() {
+ "($!x, $!y)"
+ }
+ }
+Note how the attributes are declared as C<$.x> and C<$.y> but are still
+accessed via C<$!x> and C<$!y>. This is because in Perl 6 all attributes are
+private and can be directly accessed within the class by using
+C<$!attribute-name>. Perl 6 may automatically generate accessor methods for you
+tough. For more details on objects, classes and their attributes see L<objects>.
=head1 Special Variables
=head2 Often-Used Variables

0 comments on commit 6f41c1b

Please sign in to comment.