Instant properties: length

The instant property length represents the length of a string stored within a string operand or the length of vector stored in a point operand.

Declaration

Form 1:

int32 string.length

Form 2:

float point.length

Discussion

In its first form, the read access to this property results in the number of characters stored in a string operand. If the string is empty, the property results in the value 0 (zero). Please note, this property is read-only. The write access to this property is not allowed. For example:

var string s1 = "Hello World!"; var string s2 = ""; // Get the length of the string var int32 result = s1.length; // result = 12 var int32 result = s2.length; // result = 0 // Modification is not allowed s1.length = 10; // Chora compiler error

In its second form, the read access to this property results in the length of a vector specified by the point operand. Please note, this property is read-only. The write access to this property is not allowed. For example:

var point p = <2,1>; var float result = p.length; // result = 2.23606801 // Modification is not allowed p.length = 10; // Chora compiler error

See also the built-in function math_length().