Objects can now inherit from other object declarations following the usual rules for single inheritance in object-oriented programming.
To inherit from an existing declared object, simply include the name of the parent object in parentheses after the object option in the declaration of the descendant object.
Example: Consider a simple definition of a Vehicle object:
You can derive a subclass of Vehicle called Car which inherits properties from Vehicle simply by including the parent object name in the object option when defining the module:
You can see that a Car is a Vehicle:
You can also define other objects, such as Bicycle, which inherit from Vehicle:
Notice that while a Bicycle object is a Vehicle, it is not a Car, just as you would expect:
Furthermore, if you attempt to access an export such as HasAutomaticTransmission on a Bicycle object, this results in an error, since this export is only provided for a Car object:
For more details on object inheritance, read about object creation.