Object of a class

Creating object
^class::constructor[parameters]

Constructor of a class creates an object of this class and allows further using common fields and methods of the class. For detailed description of constructors' parameters, please refer to respective chapter.
Note: the created object is accessible in $result variable and can be refefined if another object should be returned.


Calling object
^class.method[parameters]

Calls method of the class the object belongs to. For detailed description of constructors' parameters, please refer to respective chapter.
If object is not specified, this construction calls a method of the current class (if current class lacks the method called, a method of base class will be called) or an operator. In case of identical names, operator will be preferred.

Methods can be static and dynamic.


Dynamic method-code is executed within the scope of the object

Static method code is executed within the scope of the class itself, that is, deals with not a certain object but the entire class (for example, classes MAIN, math, mail)


Value of an object's field
$object.field

Retrieves the value stored in object's field.


Retreaves object's fields as a hash [3.4.0]
$h[^hash::create[$object]]

Creates a hash with object fields as keys.


Object's system field: CLASS
$object.CLASS-contains reference to the object's class

You may need this value to specify the scope of code's compilation (cf. "Process. Compiling and processing string").


Object's class name: CLASS_NAME    [3.2.2]
$object.CLASS_NAME-contains object's class name

Example:
$var[123]
$var.CLASS_NAME


This example print 'string'.



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 21.07.2016