📘 Submethods in Perl 6 classes

📘 Submethods in Raku classes

N. B. Perl 6 has been renamed to Raku. Click to read more.

Perl 6 defines the so-called submethods for classes. These are the methods which are not propagating to the subclass’s definition. The submethods may be either private or public, but they will not be inherited by the children.

class A {
    submethod submeth {
        say "A.submeth"

class B is A {

my A $a;
my B $b;

$a.submeth;   # OK
# $b.submeth; # Error: No such method 'submeth' 
              # for invocant of type 'B'

Leave a Reply

Your email address will not be published. Required fields are marked *