S2 supports several primitive types, as well as regular and associative
arrays and objects based on classes.
S2 has the following primitive types:
int
- An integer
bool
- A boolean (true/false) value
string
- A string
var int somenumber;
- Declare a simple variable named somenumber as an
integer.
var string[] names
- Declare a regular array of strings called
names.
var bool{} has_stuff
- Declare an associative array of boolean values called
has_stuff.
var SomeClass[] stuffs
- Declare a regular array of the class SomeClass and
name it stuffs.
var SomeClass{} stuffs
- Declare an associative array of the class SomeClass
and name it stuffs.
$variable
- Returns the value stored in the variable, or reference
to the regular or associative array or instance of a class with this
name.
$this
- An instance of the class the currently-executing
function was envoked from.
-
$.member, $this.member
- Equivalent ways to return the value stored in this
member of the class which owns the function being
executed.
$var.member
- Returns the value stored in this member of the
instance of a class known as
var.
$*propertyname
- Returns the value of the property specified.
$variable[2]
- Returns the value stored in element 2 (3rd element) of
the regular array.
$variable{"fred"}
- A value stored in the associative array.