Inheritance/Single: Difference between revisions
Content added Content deleted
m (→{{header|Haxe}}: 5*s->1) |
m (→{{header|J}}: 5*s->1) |
||
Line 952: | Line 952: | ||
Here is how this would normally be done: |
Here is how this would normally be done: |
||
<syntaxhighlight lang="j" |
<syntaxhighlight lang="j"> |
||
coclass 'Animal' |
|||
coclass 'Dog' |
|||
⚫ | |||
coinsert 'Animal' |
|||
<syntaxhighlight lang="j">coclass 'Cat' |
|||
coclass 'Cat' |
|||
⚫ | |||
coinsert 'Animal' |
|||
<syntaxhighlight lang="j">coclass 'Lab' |
|||
coclass 'Lab' |
|||
coinsert 'Dog' |
coinsert 'Dog' |
||
<syntaxhighlight lang="j">coclass 'Collie' |
|||
coclass 'Collie' |
|||
coinsert 'Dog' |
coinsert 'Dog' |
||
⚫ | |||
<code>coclass</code> specifies that following definitions will be within the named class, and <code>coinsert</code> specifies that the current class will inherit from the named classes (or object -- in J the only difference between a class and an object is its name and how you can create them -- this motivates the "co" prefix on operations which manipulate '''c'''lasses and '''o'''bjects). |
<code>coclass</code> specifies that following definitions will be within the named class, and <code>coinsert</code> specifies that the current class will inherit from the named classes (or object -- in J the only difference between a class and an object is its name and how you can create them -- this motivates the "co" prefix on operations which manipulate '''c'''lasses and '''o'''bjects). |