Member function that is not inherited by subclasses
A Submethod is a method that is not inherited by child classes. They are typically used for per-class initialization and tear-down tasks which are called explicitly per class in an inheritance tree, usually for enforcing a particular order. For example object construction with the
BUILD submethod happens from the least-derived to most-derived, so that the most-derived (child) classes can depend on the parent already being initialized.
Submethods are of type
Submethod, and are declared with the
Since submethods are not inherited, an interesting use case is precisely methods that are going to be called from the standard submethods such as
my Hero .= new( name => "Þor",inventory => ( "Mjölnir", "Megingjörð", "Mjölnir" ) );say .inventory;# OUTPUT: «[Megingjörð Mjölnir]␤»
Invoking these methods make sense only in the specific context of the submethod it is invoked from.
multi method gist(Submethod:)
Returns the name of the submethod.