trait is

Documentation for trait is, assembled from the following types:

language documentation Typesystem

From Typesystem

(Typesystem) trait is

Defined as:

multi sub trait_mod:<is>(Mu:U $childMu:U $parent)

The trait is accepts a type object to be added as a parent class of a class in its definition. To allow multiple inheritance the trait can be applied more than once. Adding parents to a class will import their methods into the target class. If the same method name occurs in multiple parents, the first added parent will win.

If no is trait is provided the default of Any will be used as a parent class. This forces all Perl 6 objects to have the same set of basic methods to provide an interface for introspection and coercion to basic types.

class A {
    multi method from-a(){ 'A::from-a' }
# OUTPUT: «(Any, Mu)␤» 
class B {
    method from-b(){ 'B::from-b ' }
    multi method from-a(){ 'B::from-A' }
class C is A is B {}
# OUTPUT: «A::from-a␤»