The Length Operator
The length operator is denoted by the unary operator #
. The length of a string is its number of bytes (that is, the usual meaning of string length when each character is one byte).
The length of a table t
is defined to be any integer index n
such that t[n]
is not null and t[n+1]
is null; moreover, if t[1]
is null, n
can be zero. For a regular array, with non-null values from 1 to a given n
, its length is exactly that n
, the index of its last value. If the array has "holes" (that is, null values between other non-null values), then #t
can be any of the indices that directly precedes a null value (that is, it may consider any such null value as the end of the array).