Arrays

SSharp S# API

Arrays in S# may be created in different ways. The most simple array constructor is:

[ value_1, value_2, ..., value_n]

Arrays built using this constructor will have their type of object[].

Elements of array may be accessed by index:

array[index];

Example:

 

a = [1,2,3,4]; b = a[1];

 

This is equal to following code in C#:

 

 object[] a = new object[] {1,2,3,4};
 object b = a[1];

 

There is also a custom function array which creates a typed array. There are two cases for usage array function:

  • Explicit type definition:

 

 a = array(string, 'alex', 'peter');

  • Implicit type inference:

 

 // a is of type string[]

 a = array('alex', 'peter'); 

 

 // b is of type object[]
 b = array('alex', 1, 2);