Type Methods (Extended mode)
Type methods attach behaviour to a Blitz custom Type. They are available only when the compiler or IDE language mode is set to Extended. Original mode keeps the historical language and continues to treat Method and Self as ordinary identifiers.
A method is declared after all Field declarations and before End Type:
Type {typename}
Field {fields}
Method {methodname}{typetag}( {params} )
{statements}
End Method
End TypeSelf refers to the object that received the current method call. Self cannot be assigned or redeclared, although its fields may be changed. Parameters, optional default values, Return, recursion, and the normal Integer, Float, String, and custom-Type return tags work as they do for Functions.
Call a method with mandatory parentheses. Period is the preferred Extended spelling; backslash remains supported:
player.Update()
score = player.Score()
enemies(index).Damage(amount)
entity.child.Reset()
player\Update() ; classic compatibility spellingReceivers may be variables, parameters, array elements, vector elements, Each variables, or field chains. The receiver is evaluated exactly once. Calling directly on an arbitrary temporary expression, such as New Player().Update(), is not supported; assign the value to a variable first.
Method lookup is static and belongs to the receiver's exact Type. There is no inheritance, virtual dispatch, destructors, access control, properties, or overloading. Extended mode does provide one separately defined Method New constructor per Type. A Type cannot use the same name for a Field and a Method, but different Types and global Functions may reuse a method name.
Methods do not change Blitz object lifetime rules. Objects are still created with New and explicitly removed with Delete; Type lists, Each, First, Last, Before, After, and Insert continue to behave as before. A method does not automatically own or delete its receiver. Delete Self in an ordinary method has the same risks as deleting an object parameter in a Function and is prohibited inside a constructor.
In a debug build, calling a method through Null raises the normal Blitz "Object does not exist" runtime error before the method body begins.
See the complete Type-method example.