!
ErrorsCollection

!

Synthesised documentation from language/variables

From language/variables

See Original text in context

Attributes are variables that exist per instance of a class. They may be directly accessed from within the class via !:

my class Point {
    has $.x;
    has $.y;
 
    method Str() {
        "($!x$!y)"
    }
}

Note how the attributes are declared as $.x and $.y but are still accessed via $!x and $!y. This is because in Raku all attributes are private and can be directly accessed within the class by using $!attribute-name. Raku may automatically generate accessor methods for you though. For more details on objects, classes and their attributes see object orientation.