Cind language documentation
An array is a finite ordered set of objects,
which are numbered from 0 to N-1,
where N is the number of elements in array (named a length of array).
An array is a structure of objects but also an object itself,
what means that it can responds to the messages and be handled in the variable as a value.
Once created array can not change its length, but it can change its elements.
There are two ways to create array: explicitly by indicating elements
or by using instruction new.
["Red","Green","Blue"] // 3-elements array of strings
 // 0-elements array
[0,true,"Hello",x,(y,z)] // array of objects of misc types
[1,2,,,5] // [1,2,null,null,5]
Examples of arrays created explicitly by indicating elements (and separating them with commas):
Instruction new creates an array of given length and element type.
new object; // array of length 10 of objects of any type
new int; // array of length 10 of integer values
new int; // 2-dimensional array 8x6 of integers
new int; // array of length 20 of objects of type int
new a.b.c; // array of objects of class a.b.c
This array will be initially filled with null objects (see Objects and null value).
For more variants of instruction new see Creating objects.
Assuming that y is an array of length N,
and k is an integer from 0 to N-1,
x = y[k]; // reading element
y[k] = z; // writing element
y[k]++; // increment value at given position
y[k] += 10; // assignment operator called on the element, not on array
then accessing elements at position k
can be realized by a syntax y[k],
which is called an element operator (see on the bottom of this page).
When k is a value less then 0 or greater then N-1
then accessing y[k] will throw an exception.
[a,b,c] = y;
Elements of array can be also restored by special syntax:
which is equivalent to executing list of instructions:
a = y;
b = y;
c = y;
All array's accessing instructions are not an atomic instructions,
and may be concurrently called by a number of threads.
Type of array
An array type notation consists of a type of an element
and an empty bracket  added from the right side.
is a type of array of integer values, and:
is a type of array of arrays of integers
(or 2-dimensional array of integers, if you prefer).
int x = [1,2,3];
int y = new int;
int z = [x,y];
object t = [x,y,z];
An array without declared type of element has type
(for about an object type see Objects and null value).
A type cast operator and a type conversion methods called on the array object,
will not change the object, but only checks, whenever given array match to given type.
x = (string)y;
For example, this instruction:
checks whenever y is an array of strings, and if so, then sets x = y,
and if it is not, then it will throw an appropriate exception.
For more about type conversion see Type conversion,
and for more about data types see Data types.
Methods accepted by the array object:
||returns new array with the same length and elements
||returns element at given position
||returns new array with inversed list of elements
||iteration - sequential function call for each element in the array
||array of results
||length of array
||puts element at given position
||returns new sub array starting at given position
||returns new vector containing elements from the array
string y = ["veni","vidi","vici"];
int pos = y.length();
host.println("on position: " + (--pos) + " there is: " + x);
Notice, that vector returned by toVector method may has different length from the original array,
because of its conversion to the linear form (see Vector of values).
Element operator allows to access elements of an array,
or elements of any other structures,
that accepts analogous methods get and put
to the array object.
Syntax of an element operator is:
where x is the parent structure (for example, array),
and y is a selected position of the element.
a = b[c]; --> a = b.get(c);
a[b] = c; --> a.put(b,c);
a = b[c][d]; --> a = b.get(c).get(d);
a[b][c] = d; --> a.get(b).put(c,d);
a[b] = c[d]; --> a.put(b,c.get(d));
a[b]++; --> t = a.get(b); t++; a.put(b,t);
In case of array, parameter y will be converted to integer value.
Depending on the access way to the element, an element operator will be converted,
by the compiler or by the program execution software,
to the get or put methods of the called structure,
which will be executed to access selected element.
Element operator is not an atomic instruction, and its execution may be divided into parts,
which call may be interlaced by the other concurrently executed methods.
For more about concurrent access see Concurrent expressions.