diff options
author | def <dennis@felsin9.de> | 2015-03-26 18:08:58 +0100 |
---|---|---|
committer | def <dennis@felsin9.de> | 2015-03-26 18:08:58 +0100 |
commit | 91ed170523093c17119af674666263ff0ab69b7b (patch) | |
tree | 43050d211411ab026998965301b799f40f46278c /doc/tut2.txt | |
parent | 91708bb21dfea35e178186f8820c7972d3832a67 (diff) | |
download | Nim-91ed170523093c17119af674666263ff0ab69b7b.tar.gz |
Rework explanation a bit (thanks flaviu)
Diffstat (limited to 'doc/tut2.txt')
-rw-r--r-- | doc/tut2.txt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/tut2.txt b/doc/tut2.txt index 744003685..e1ac20074 100644 --- a/doc/tut2.txt +++ b/doc/tut2.txt @@ -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 in the GTK wrapper for instance.) -We always use ref objects for inheritance in this tutorial. When you store a -non-ref object in a variable of a parent type, the additional fields are cut -off. +Ref objects should be used whenever inheritance is used. It isn't strictly +necessary, but with non-ref objects assignments such as ``let person: Person = +Student(id: 123)`` will truncate subclass fields. **Note**: Composition (*has-a* relation) is often preferable to inheritance (*is-a* relation) for simple code reuse. Since objects are value types in |