lua-users home
lua-l archive

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


On Tue, Oct 11, 2011 at 7:22 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> I'm trying to guess what you mean by "overwritten inside the loop".

I don't know why you have to "guess" something as obvious as this, but
have at it.

stuff = {"red", "green", "blue"}
for _, arg in pairs(stuff) do
    -- arg is no longer the "commandline argument vector" here.
    -- anyone who has mastered the Lua tutorial should know that.
    print("stuff:", arg)
end

-- but since 'arg' is local to the for loop, it is only overwritten
__inside__ the for loop.
for _, s in pairs(arg) do print("arg:", s) end