WoW:API pairs: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Change category from "LUA Functions" to "Lua functions".) |
||
Line 1: | Line 1: | ||
Native Lua statement: | |||
Used in loop constructs to iterate through the values of a table, with index beeing anything. | Used in loop constructs to iterate through the values of a table, with index beeing anything. | ||
Line 28: | Line 28: | ||
would be output to the chat window. | would be output to the chat window. | ||
{{LUA}} | |||
{{ |
Revision as of 12:15, 26 May 2006
Native Lua statement:
Used in loop constructs to iterate through the values of a table, with index beeing anything.
Example:
local random_array = { mug = "coffee", [42] = "universe", true = "false" }
for index,value in pairs(fruits) do if (type(index) == "number") then index = tostring(index) elseif (type(index) == "boolean") then if (index) then index = "true" else index = "false" end end DEFAULT_CHAT_FRAME:AddMessage(index.." : "..value) end
Result:
mug : coffee 42 : universe true : false
would be output to the chat window.