Lua Programming/How to Lua/symbols/hash

Length operatorEdit

The hash symbol acts as a unary length operator.

Length of a stringEdit

When used against a string, the length operator returns the number of bytes within the string.

Length of a tableEdit

When used against atable that is not sparse, the length operator returns the number of the last non null element in the table. For an empty table, a value of zero will be returned:

Sparse tablesEdit

Note that if a table contains holes, the length operator considers the first null element to be the end of the table, and will return the element number that immediately precedes the null element.

Last modified on 13 June 2011, at 23:41