lua-users home
lua-l archive

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


If you're looking through the Lua documentation or mailing lists, bear in mind the built-in associative map type is consistently called "table" rather than "dictionary".

'for k,v in pairs(effectsTable[widgetTableIndex])' will iterate through the keys and values of the table 'effectsTable[widgetTableIndex]'. 'k' is the key at which 'v' is stored, so 'effectsTable[widgetTableIndex][k] = nil' will remove that entry from the table.

Hope that helps,
Chris

----- Original Message ----- From: "Dan" <balaam@gmail.com>
To: <lua@bazar2.conectiva.com.br>
Sent: Monday, January 28, 2008 2:52 PM
Subject: Newbie Dictionary Question


Hello I'm having fun using Lua but there's a problem I can't seem to
find a simple solution to


    for k,v in pairs(effectsTable[widgetTableIndex]) do
                  print(k,v)
                  local alive = coroutine.resume(v)

                   if (not alive) then
                       v = nil;
                   break;
                   end;
              end

I want to remove the coroutines that are dead in this dictionary. K is
a table, V is a coroutine. Remove takes an integer. Is there a a line
of code that will remove an entry, currently I have v = nil. But I
want to remove the entry entirely. What's the best way to go about
doing this?

Thanks for any help!

-Dan