lua-users home
lua-l archive

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


On Wed, Dec 29, 2010 at 3:18 PM, Daniele Alessandri
<suppakilla@gmail.com> wrote:
> Which one is right? I guess Lua, even if
> http://www.lua.org/manual/5.1/manual.html#2.5.5 states that "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).".
>
> I would expect at least the same behavior, or am I just doing it wrong
> by trying to rely on the current one showed by Lua 5.1?

They are both right. As the manual states, in cases like these, there
are multiple "right" lengths, and implementations are free to give you
any of the "right" lengths. Hence relying on all implementations
giving the same result is bad practice, as this isn't guaranteed.