%This
In Java and .NET languages the this keyword refers to the current object. In DataBasic the equivalent %This special method is generally not required. However elements in an array object cannot be accessed directly because the DataBasic compiler cannot distinguish between square brackets [] being used for string extraction or for array access.
%This cannot recurse through nested array objects.
All special method names and keywords are case-insensitive.
Syntax
object->%This(Field, n)
Syntax elements
objectAn expression that evaluates to an internal array object.
nAn array index; array indices start at 0.
Applicability
Internal objects only.
Example
Note that undefined array elements are initialised to null.
Fibonacci = %Array() Fibonacci->%This(Field, 0) = 0 Fibonacci->%This(Field, 1) = 1 Fibonacci->%This(Field, 3) = 2 PRINT Fibonacci->%ToJSON(1)
which produces:
[ 0, 1, null, 2 ]