parents
ErrorsCollection

parents

Synthesised documentation from type/Metamodel/MultipleInheritance

From type/Metamodel/MultipleInheritance

See Original text in context

method parents($obj:$all:$tree)

Returns the list of parent classes. By default it stops at Cool, Any or Mu, which you can suppress by supplying the :all adverb. With :tree, a nested list is returned.

class D { };
class C1 is D { };
class C2 is D { };
class B is C1 is C2 { };
class A is B { };
 
say A.^parents(:all).raku;
# OUTPUT: «(B, C1, C2, D, Any, Mu)␤» 
say A.^parents(:all:tree).raku;
# OUTPUT: «[B, ([C1, [D, [Any, [Mu]]]], [C2, [D, [Any, [Mu]]]])]␤»