From Xojo Documentation
Used in a module method declaration to indicate that the method is to be called using the dot operator ("."), as if it were an object method of the first parameter.
Extends parameter As dataType
|parameter||same type as dataType||The name of the first parameter. If parameter is Nil, the Extends method is not executed, and a NilObjectException is generated.|
|dataType||data type or class||The data type for which the method can be called.|
The Extends keyword allows you to call a user-defined method as if it were part of a class. You use the Extends keyword only for the first parameter in the method declaration. Extends indicates that this parameter is to be used on the left side of the dot operator. The remaining parameters in the declaration, if any, are used normally.
Methods declared in this way are sometimes called "class extension methods" even though they are not actually part of a class. You can use Extends only for methods in a module. Extends cannot be used to override another method. Extension methods are not virtual, since they are not part of a class.
Extension methods are an example of "syntactic sugar". There is no difference in capability between an extension method and a normal module method; each simply specifies a particular calling syntax. (Many built-in methods are provided in both versions, so that either calling syntax will work.) Extension methods can make calling code more regular and readable, and if used consistently, can make it easier to remember which syntax to use. On the other hand, extension methods can make the dependency of a class on a module less obvious to a programmer.
Extends can allow more readable and concise calling code. This example extends the String data type with a function that determines whether one string contains another. In a module, create this function:
Return Container.InStr(Contained) > 0
The Extends keyword indicates that the first parameter does not appear in the parameter list of the actual method call. Instead, it is used on the left side of the dot operator. The remaining parameter is used normally:
Without Extends, the method call would be functionally equivalent, but less clear in meaning:
Here's another example: controls and windows have built-in Left and Top properties, but not Bottom and Right properties. You can simulate these using Extends:
Return ctl.Left + ctl.Width
Function Bottom(Extends ctl As RectControl) As Integer
Return ctl.Top + ctl.Height
As with the previous example, the Extends keyword indicates that the first parameter is used before the dot operator. Since there are no other parameters, calls to these methods don't use a parameter list. Here's how you might use these functions to place a button below a text field, and to align it with the text field on the right:
MyButton.Left = MyTextField.Right - MyButton.Width