Rework explanation a bit (thanks flaviu)
This commit is contained in:
parent
91708bb21d
commit
91ed170523
1 changed files with 3 additions and 3 deletions
|
|
@ -83,9 +83,9 @@ no ancestor are implicitly ``final``. You can use the ``inheritable`` pragma
|
||||||
to introduce new object roots apart from ``system.RootObj``. (This is used
|
to introduce new object roots apart from ``system.RootObj``. (This is used
|
||||||
in the GTK wrapper for instance.)
|
in the GTK wrapper for instance.)
|
||||||
|
|
||||||
We always use ref objects for inheritance in this tutorial. When you store a
|
Ref objects should be used whenever inheritance is used. It isn't strictly
|
||||||
non-ref object in a variable of a parent type, the additional fields are cut
|
necessary, but with non-ref objects assignments such as ``let person: Person =
|
||||||
off.
|
Student(id: 123)`` will truncate subclass fields.
|
||||||
|
|
||||||
**Note**: Composition (*has-a* relation) is often preferable to inheritance
|
**Note**: Composition (*has-a* relation) is often preferable to inheritance
|
||||||
(*is-a* relation) for simple code reuse. Since objects are value types in
|
(*is-a* relation) for simple code reuse. Since objects are value types in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue