WoW:API ipairs

Revision as of 21:58, 22 July 2005 by WoWWiki>Kilan
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Wrapper for lua function ipairs(t):

Used in loop constructs to iterate through the values of a table where there is no index (an array).

Example:

local fruits={"apple","orange","banana",kiwi"}
for index,value in ipairs(fruits) do 
  DEFAULT_CHAT_FRAME:AddMessage(tostring(index).." : "..value)
end

Result:

 1 : apple
 2 : orange
 3 : banana
 4 : kiwi

would be output to the chat window.