Object
The obj type is used to store values of the following types - int, bool, float, str, arr.obj, map.obj. If no value is assigned to the object, then it is equal to nil. An object can be assigned values of a type that is different from the current one. The operators and functions for working with objects are described here.
Types
fn cmpobjfunc(obj, obj) int
The cmpobjtype function type is used to compare two objects. Functions of this type are used to sort objects in an array.
Operators
Operator
Result
Description
*obj
int
If the object is arr.obj or map.obj, the number of items in the array is returned. Otherwise, it returns 0.
obj ?
bool
Calls bool(obj).
obj = arr.typename
obj
Assigning an array to an object.
obj = bool
obj
Assigning a boolean value to an object.
obj = float
obj
Assigning a decimal number to an object.
obj = int
obj
Assigning a number to an object.
obj = map.typename
obj
Assigning an associative array to an object.
obj = obj
obj
Assignment operator.
obj = str
obj
Assigning a string to an object.
obj += obj
obj
Adding an object to an array of objects.
obj &= obj
obj
Creates a clone of the object. The new variable will work with the same data set.
obj [ int/str ]
obj
Assign / get the value of an array by index. If the object is not arr.obj or map.obj, then an error occurs.
Functions
arr(obj o) arr.obj
The arr function returns an array of objects. Object o must be an array, otherwise it returns an error. Calling the function does not create a new array, but returns the current array that contains the o object.
arrstr(obj o) arr.str
The arrstr function converts an array of objects into an array of strings. The o object must be an array, otherwise an error is returned. The function returns the resulting array of strings.
bool(obj o) bool
The bool function returns a logical value of the current type. For example, if an object contains a string, the result of calling bool(str) is returned. If the object is not defined, an error is returned.
bool(obj o, bool def) bool
The bool function returns a logical value of the current type. If the object is not defined, the second parameter is returned.
float(obj o) float
The float function converts an object to a decimal floating-point number. The object must contain a value of str, int, float type, otherwise, an error occurs.
float(obj o, float def) float
The float function converts an object to a decimal floating-point number. If the object is not defined, the second parameter is returned.
int(obj o) int
The int function converts an object to an integer. The object must contain a value of str, int, float, bool type, otherwise, an error occurs.
int(obj o, int def) int
The int function converts an object to an integer. If the object is not defined, the second parameter is returned.
IsArray(obj o) bool
The IsArray function returns true if the object is an array. Otherwise, the function returns false.
IsMap(obj o) bool
The IsMap function returns true if the object is an associative array (map). Otherwise, the function returns false.
IsNil(obj o) bool
The IsNil function returns true if the object is undefined (equal to nil). Otherwise, the function returns false.
item(obj o, int i) obj
The item function returns the i-th element of the object. The object must be of arr.obj type. If the element is missing, then an empty object is returned.
item(obj o, str s) obj
The item function returns the value of key s. The object must be of map.obj type. If there is no element, it returns an empty object.
map(obj o) map.obj
The map function returns an associative array of objects. The o object must be an associative array (map), otherwise an error is returned. When the function is called, no new array is created, but the current map which contains object o is returned.
obj(arr.typename a) obj
The obj function converts an array of the arr type into an object.
obj(bool b) obj
The obj function creates an object with the specified logical value.
obj(float f) obj
The obj function creates an object with the specified float value.
obj(int i) obj
The obj function creates an object with the specified int value.
obj(map.typename m) obj
The obj function converts an associative array of the map type into an object.
obj(str s) obj
The obj function creates an object with the specified str value.
Sort(arr.obj o, cmpobjfunc cmpfunc) arr.obj
The Sort function sorts an array of objects and returns it. Sorting is done using a function of cmpobjfunc type.
str(obj o) str
The str function converts the object to a string and returns it.
str(obj o, str def) str
The str function converts the object to a string and returns it. If the object is not defined, the second parameter is returned.
Type(obj o) str
The Type function returns the value type of the specified object. The following types may be returned: int, bool, float, str, arr.obj, map.obj. If the object is undefined, then nil is returned.
Last updated