Complicated List/Array Insert and Remove

Posted by Curious2 on Sat 24 Jan 2009 03:19 AM — 2 posts, 11,476 views.

#0
How could I use a table/array to keep a list of two related items. Then pass those two items to function.

Example:

function dostuff(a, b)
doA(a)
doB(b)
end

Is it possible to keep a bunch of "a and b"s in an array then use table.remove and send those two elements to the dostuff function? I also need to add new items as well with table.insert. Once the list is empty I repopulate it again.

I suppose I need to make two tables instead? I think I confused myself trying to figure out the best way to do this.
#1
Haha never mind. It was so easy I confused myself.

list = {
{a = "stuff", b = "morestuff"},
{a = "stuff", b = "morestuff"},
{a = "stuff", b = "morestuff"}
}

function stuff()
local temp = table.remove(list, 1)
dostuff(temp.a, temp.b)
end

function dostuff(a, b)
doA(a)
doB(b)
end