lua-users home
lua-l archive

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


Philippe Lhoste wrote:
> A for statement like
>        for index, value in exp do block end
>
> I am probably thick (still a newbie here, lurks a lot, doesn't codes much
> Lua yet), but how this differ deeply from your:
> >>>
>     for val in list do
>         print(val)
>     end
> <<<

Table iteration using "for index, value" does not guarantee any ordering,
which is often required for lists.  If order is not important it's possible
to use "for index, value" on a list, but be careful about the n field that
may be inserted by some library functions which would cause the iteration to
break.

-John