An array is one of the types of TRIK Studio language that stores a set of values (array elements) identified by an index. The numbering of indices in the array starts at 0.
Arrays can be created explicitly using the following expressions (the next lines are equivalent):
Or with explicit indices:
You can use arrays without creating them. For example, like this:
In this case, "empty spaces" in the array (indices that did not have an explicit assignment) will be filled with default values:
0
— for real and integer;
false
— for boolean;
empty lines for arrays of strings.
Array values can also be used without curly braces if used as the return value. For example, this expression will return an array of numbers 1
and 2
:
This is implemented in order to interpret the enumerations of values (for example, the ports of motors in the block "Motors forward") as arrays. Therefore, wherever you use a comma-separated value notation, you can use an array.
Unlike Lua, the TRIK Studio language is statically-typed, that is, the type of each expression and each variable must be known at compile time. Moreover, the language does not require (and does not even allow!) to explicitly write the types of variables. It uses automatic type inference for the use of variables.
For example, environment "understands" from the expression a = 1
that type of a
is integer.
Type
Description
Boolean (logic) type
Can be one of two values: true or false.
Real
Uses IEEE 754 64-bit binary64 representation (allows to store values up to 1.7E+308).
Integer
Uses 32-bit signed representation (allows to store values in a range from -2 147 483 648 to 2 147 483 647).
String
Allows storing character strings of arbitrary length in UTF-8 encoding.
Null type
It has only a one-nil value and means the absence of any other value type.
Allows storing an arbitrary number of values of an arbitrary (but for each value in the same array of the same) type, including other arrays, and access values by index.
See the article about the syntax of expressions in blocks: