View Single Post
05/12/14, 06:18 PM   #6
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
If that code fragment is exactly the same and not just an example, then ditch the table name of "table". Use something else. Table is a special "word" in LUA.

Also, if you decide to use two parameters for pairs/ipairs/next, take advantage of it. All of these below are equivalent:

Code:
for k in next, renamedTable do
d(renamedTable[k])
end

for k, v in next, renamedTable do
d(v)
end

for k in pairs(renamedTable) do
d(renamedTable[k])
end

for k, v in pairs(renamedTable) do
d(v)
end
Note that "ipairs" is not up there. It is different than "pairs". "next" is basically included in the pairs, as I've said, all above will give you the same results, and you can use "local next = next" to speed up the process a little bit (by nanoseconds :P)

Last edited by lyravega : 05/12/14 at 06:22 PM.
  Reply With Quote