Lua, table size (#table_name or table.getn (table_name), sometimes returns 0

When #table_namedoes the value return not 0? And again, when table.getn(table_name)returns a non-0 value?

+3
source share
2 answers

Go through the manual:

2.5.5 - Length Operator

The length operator is denoted by the unary operator #. String length is the number of bytes (which is the usual value for string length when each character is one byte).

t n , t [n] nil t [n + 1] nil; , t [1] nil, n . -nil 1 n, n, . "" ( nil -nil ), #t , nil ( nil, ).

+7

(, ), 0.

+3

All Articles