Member Variables

A member variable is a variable that is associated with a specific object, and accessible for all its member methods.

Declaring Member Variables

When declaring a member variable, its data type must be specified. The declaration methods vary based on the data type of the variables:

Scalars

Scalars include basic data types such as INT, CHAR, FLOAT, DOUBLE, STRING, etc. The declaration method is: variableName :: dataType. For example: age :: INT, name :: STRING.

Regular Vectors

When declaring member variables as regular vectors, the method is similar to declaring scalars, but you need to add VECTOR after the data type to indicate that the member variable is a regular vector. The declaration method is: variableName :: dataType VECTOR. For example: age :: INT VECTOR, name :: STRING VECTOR.

Array Vectors

When declaring member variables as array vectors, the method is similar to declaring regular vectors, but you need to add [] after the data type to indicate that the member variable is an array vector. The declaration method is: variableName :: dataType[] VECTOR. For example: age :: INT[] VECTOR.

Retrieving Member Variables

Provides the attributeNames and attributeValues methods to retrieve all member variable names and their corresponding values of a class instance.

class Person {
	
	name :: STRING
	age :: INT

	def Person(name_, age_) { 
		name = name_
		age = age_
	}
}

p = Person("Sam", 12)
attributeNames(p)
// output: ["name","age"]

attributeValues(p)
/* output:
name->Sam
age->12
*/