Skip to content

Commit 24355d0

Browse files
authored
In section Inheritance_and_multis of typesystem.rakudoc, clarify wording and code example (#4635)
* In section `Inheritance_and_multis` of `typesystem.rakudoc`, clarify wording and code Replace the ambiguous "does not compete with" with a phrase that's clearer and easier to parse. In the code, change class names `A` and `B` to `Parent` and `Child`, and add comment that `int` is a subclass of `Int` (which is important to know in order to understand what goes on). * Update typesystem.rakudoc: Change example types to `Numeric` & `Int`
1 parent 8b677e1 commit 24355d0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

doc/Language/typesystem.rakudoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,20 @@ first argument.
208208

209209
=head4 Inheritance and multis
210210

211-
A normal method in a subclass does not compete with multis of a parent class.
211+
For a normal method in a subclass, there is no competition from multi methods in a parent class.
212212

213-
class A {
213+
class Parent {
214+
multi method m(Numeric $i){ say 'Numeric' }
214215
multi method m(Int $i){ say 'Int' }
215-
multi method m(int $i){ say 'int' }
216216
}
217217

218-
class B is A {
219-
method m(Int $i){ say 'B::Int' }
218+
class Child is Parent {
219+
method m(Numeric $i){ say 'Child::Numeric' }
220220
}
221221

222-
my int $i;
223-
B.new.m($i);
224-
# OUTPUT: «B::Int␤»
222+
my Int $i;
223+
Child.new.m($i);
224+
# OUTPUT: «Child::Numeric␤»
225225

226226
X«|Syntax,only method»
227227
=head4 Only method

0 commit comments

Comments
 (0)