Built-in variables: this

Strictly speaking, this is not a real built-in variable but a hidden parameter available exclusively in all methods. It refers to the current object, in context of which the method is executed. The data type of this corresponds exactly to the class of the object.

Declaration

class‑of‑the‑object this

Discussion

The variable this provides a convenient way to access the current object instance. Because of the current object is always valid, this variable will never become null.

You can use the variable this within expressions wherever an object operand is allowed. For example you can pass it as an argument in a method call or you can store it in a member of another object.

var SomeUnit::SomeClass anotherObject = ... anotherObject.SomeMethod( this ); anotherObject.SomeVariable = this;