๐Ÿ“˜ 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 *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code