Inheritance/Single: Difference between revisions
Latitude language added
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
Mercerenies (talk | contribs) (Latitude language added) |
||
Line 1,057:
#myanimal -> gender</lang>
-> Male
=={{header|Latitude}}==
Latitude is a prototype-oriented language, so defining a subclass is equivalent to constructing an instance.
<lang latitude>
Animal ::= Object clone tap {
;; Methods go here...
}.
Dog ::= Animal clone tap {
;; Methods go here...
}.
Cat ::= Animal clone tap {
;; Methods go here...
}.
Lab ::= Dog clone tap {
;; Methods go here...
}.
Collie ::= Dog clone tap {
;; Methods go here...
}.</lang>
We <code>clone</code> the parent and then <code>tap</code> the new instance to add functionality to it. Note that we use <code>::=</code> here rather than the usual <code>:=</code>, as the former implicitly defines an appropriate <code>toString</code> method representative of the new "class".
=={{header|Lingo}}==
|