Classes and objects
Perl 6 has formal support for classes, objects, and roles:
class Dog is Mammal does Pet { has $.name = "fido"; # public read-only has $.tail is rw; # public read-write has @.legs; # public read-only array has $!brain; # private scalar method feed ($food) { ... } ... } my Dog $fido .= new; $fido.feed('bone'); say $fido.name;