<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Language > Data types and variables > TYPE (ord UDT User Defined Types) > UDT (User Defined Types) > Extending existing UDT >





ThinBASIC offers the extends keyword to create new UDT by extending existing UDT.


In our case, creating Point3D would be as straightforward as:




Now, the Point3D will have new z element, while the x and y will be inherited from Point2D.


Note: The elements of base UDT will be placed as first in the newly created UDT


Note: In case you would add new element to base UDT, it will get promoted to UDT which extends it.


Note: In case you would reorder the elements in base UDT, they will get reordered in UDT which extends it.