lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


* Gavin Wraith:

> Is the following a correct restatement of what #t means for a table t?
>
>  The length, #t, of a table t may take different values, but is
> guaranteed to be 0 if t[1] is nil and to be n if t[n+1] is nil
> and t[m] is not nil for all positive integers m less than n+1.

I think that that implication goes into the wrong direction.  It
should be something like: if #t == n, then n == 0 and t[1] == nil, or
t[n] != nil and t[n + 1] == nil.  This can be simplified slightly to:
if #t == n, then (n == 0 or t[n] != nil) and t[n + 1] == nil.