Inheritance/Single: Difference between revisions
Content added Content deleted
m (→{{header|JavaScript}}: 2*s->1) |
m (→{{header|Lingo}}: 5*s->1) |
||
Line 1,156: | Line 1,156: | ||
=={{header|Lingo}}== |
=={{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). |
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"> |
<syntaxhighlight lang="lingo"> |
||
-- parent script "Animal" |
|||
⚫ | |||
-- ... |
|||
-- parent script "Dog" |
|||
property ancestor |
property ancestor |
||
Line 1,165: | Line 1,166: | ||
me.ancestor = script("Animal").new() |
me.ancestor = script("Animal").new() |
||
return me |
return me |
||
end |
|||
end</syntaxhighlight> |
|||
-- parent script "Cat" |
|||
property ancestor |
property ancestor |
||
Line 1,173: | Line 1,174: | ||
me.ancestor = script("Animal").new() |
me.ancestor = script("Animal").new() |
||
return me |
return me |
||
end |
|||
end</syntaxhighlight> |
|||
-- parent script "Lab" |
|||
property ancestor |
property ancestor |
||
Line 1,181: | Line 1,182: | ||
me.ancestor = script("Dog").new() |
me.ancestor = script("Dog").new() |
||
return me |
return me |
||
end |
|||
end</syntaxhighlight> |
|||
-- parent script "Collie" |
|||
property ancestor |
property ancestor |
||
Line 1,189: | Line 1,190: | ||
me.ancestor = script("Dog").new() |
me.ancestor = script("Dog").new() |
||
return me |
return me |
||
end |
|||
end</syntaxhighlight> |
|||
⚫ | |||
=={{header|Lisaac}}== |
=={{header|Lisaac}}== |