WoW:API pairs: Difference between revisions

No change in size ,  3 November 2008
m
Changed layout slightly, corrected spelling
(fixed bug in in the example ("local random_array"..."pairs(fruits)"))
m (Changed layout slightly, corrected spelling)
Line 1: Line 1:
Native Lua statement:
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 being anything.


Example:
Example:


  local random_array = { mug = "coffee", [42] = "universe", true = "false" }
  local random_array = { mug = "coffee", [42] = "universe", true = "false" }
 
  for index,value in pairs(random_array) do  
  for index,value in pairs(random_array) do  
   if (type(index) == "number") then
   if (type(index) == "number") then
Anonymous user