Summary
In this chapter, we learnt about object-oriented support in Perl 6. We went through creating a class, adding attributes and methods to it, and making the methods and class data public or private. We then talked about class hierarchy and an alternative approach using roles and also how to use Perl 6 built-in facilities for introspecting the objects. On a set of examples, we examined many techniques of working with complex objects. Finally, the postfix method operators were listed, with which you may create more universal and robust programs.
In the next chapter, exceptions are described. In Perl 6, they are based on classes, so the knowledge from the current chapter will be very useful for better understanding exceptions.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access