lua-users home
lua-l archive

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


Jose Torre-Bueno <jtorrebueno <at> cox.net> writes:
> On Apr 16, 2012, at 1:58 AM, Dirk Laurie wrote:
> > Op 16 april 2012 10:31 heeft  <csrl <at> gmx.com> het volgende geschreven:
> >> I'm trying to reconcile documentation to the surprising behavior of the
length operator on a table.
> >> 
> >> Please refer to http://www.lua.org/manual/5.2/manual.html#3.4.6
> >> 
<snip>
> From the manual:
> The length of a table t is defined to be any integer index n such that
> t[n] is not nil and t[n+1] is nil; moreover, if t[1] is nil, n CAN be
> zero. For a regular array, with non-nil 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, nil values between other non-nil values),
> then #t CAN be any of the indices that directly precedes a nil value
> (that is, it may consider any such nil value as the end of the array)"

You quoted the 5.1 manual, not 5.2.  However, it does seem that the 5.1 manual
text is somewhat clearer than 5.2, if "CAN" were to be elaborated on.

chris