lua-users home
lua-l archive

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

Perhaps I'm dense. I ran the OP's example and got the same result,
then I changed the table.foreach loop into the for k,v in pairs(args)
variant, and it worked as expected. Clearly you guys understand why,
but I don't see it. Could someone please explain?

2008/12/6 Miles Bader <>:
> "pan shizhu" <> writes:
>> It is quite normal to use table.foreach and made this kind of mistake. I
>> think this might be the reason to obsolete table.foreach. Please note that
>> table.foreach is officially obsoleted. Use  for k,v in pairs(table) instead,
>> which is less prone for mistake.
> Using "for" is better for code, but table.foreach is often more
> convenient for interactive use.
> -Miles
> --
> Love is a snowmobile racing across the tundra.  Suddenly it flips over,
> pinning you underneath.  At night the ice weasels come.  --Nietzsche