class_add_cvar

class_add_cvar — adds new class variables.

Syntax

class_add_cvar (class variable init_value? type?);

		

Arguments

class

The class receiving the new class variable.

variable

The new variable to add to the class.

init_value

Optional argument for initial value of the variable.

type

Optional argument for the type of variable.

Returns

The value of the new argument.

Description

This function adds new class variables to either binary (built-in) or user-defined classes. Class variables are special variables that are available to be set/read by any instance of the class, as well as any derived classes or their instances, whether they were created before or after the class variable was defined.

Example

[Note]

This example is based on the class and method developed in method.

Gamma> class_add_cvar(RegPolygon, #linethickness, 2);
2
Gamma> polyD = new(RegPolygon);
{RegPolygon (length) (sides)}
Gamma> polyD.linethickness;
2
Gamma> sqB.linethickness;
2
Gamma> 
		

See Also

class_add_ivar