In OOP, objects not only keep data, but also do some actions. In Perl 6, data is saved in attributes, and actions are done via methods.
Methods are like regular subs but defined inside a class. They can use the data from object attributes for their work.
Continue with the Address class from the previous sections. The details of the address are kept in separate attributes. This is good for creating a clean and structured representation but, in some cases, we need all data to be used together. For example, let's print a formatted address to put on an envelope:
class Address {
has Str $.housenumber;
has Str $.zipcode;
has Str $.country;
has Str $.town;
has Str $.street;
}
my $address = Address.new(
housenumber => '10',
zipcode => '1020',
country => 'Country',
town => &apos...