Inheritance/Single: Difference between revisions

m
Line 1,156:
=={{header|Lingo}}==
In Lingo Classes are represented by "parent scripts". Instead of using new() as in the code below, child classes can also use rawNew() when creating an instance of their parent classes. rawNew() creates an instance of a class without calling its initialization function 'new' (constructor).
<syntaxhighlight lang="lingo">-- parent script "Animal"
-- parent script "Animal"
-- ...</syntaxhighlight>
-- ...
 
<syntaxhighlight lang="lingo">-- parent script "Dog"
property ancestor
 
Line 1,165 ⟶ 1,166:
me.ancestor = script("Animal").new()
return me
end
end</syntaxhighlight>
<syntaxhighlight lang="lingo">-- parent script "Cat"
property ancestor
 
Line 1,173 ⟶ 1,174:
me.ancestor = script("Animal").new()
return me
end
end</syntaxhighlight>
 
<syntaxhighlight lang="lingo">-- parent script "Lab"
property ancestor
 
Line 1,181 ⟶ 1,182:
me.ancestor = script("Dog").new()
return me
end
end</syntaxhighlight>
 
<syntaxhighlight lang="lingo">-- parent script "Collie"
property ancestor
 
Line 1,189 ⟶ 1,190:
me.ancestor = script("Dog").new()
return me
end
end</syntaxhighlight>
-- ...</syntaxhighlight>
 
=={{header|Lisaac}}==
7,794

edits