Skip to content

Commit cfb08c8

Browse files
committed
show that methods overrule multis of parent classes
1 parent f5020e2 commit cfb08c8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/Language/typesystem.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,23 @@ such they can not be altered from outside the class they are defined in.
166166
X«|method (declarator)»
167167
=head3 Methods
168168
169+
=head4 Inheritance and Multies
170+
171+
A normal method in a subclass does not compete with multies of a parent class.
172+
173+
class A {
174+
multi method m(Int $i){ say 'Int' }
175+
multi method m(int $i){ say 'int' }
176+
}
177+
178+
class B is A {
179+
method m(Int $i){ say 'B::Int' }
180+
}
181+
182+
my int $i;
183+
B.new.m($i);
184+
# OUTPUT«B::Int␤»
185+
169186
X«|only method»
170187
=head4 Only Method
171188

0 commit comments

Comments
 (0)