Inheritance

From HEWIKI
Jump to: navigation, search

Inheritance allows one class to include the fields and methods of another class. A class can inherit from one or more other classes.

When a class inherits from another class, the node that is instantiated from that class includes a single copy of all of the fields defined by its class and all inherited classes. This also means any classes inherited by that class, and so on down the line.

Field inheritance

Let's say we have some classes defined this way:

Also assume that class MIGHTY inherits from both class FOO and class BAR.

A node instantiated from class MIGHTY would then have fields, A, B, C, D, E, F, G and H.

Notice that MIGHTY has one field named B and one field named C even though they appear multiple times in the hierarchy. This is a unique distinction in HeroScript that is not common in other object-oriented languages.

Method inheritance

Any available Method can be called on a Node based on what class(es) the node is derived from.

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox