WoW:API pairs: Difference between revisions

27 bytes added ,  15 August 2023
m
Move page script moved page API pairs to WoW:API pairs without leaving a redirect
No edit summary
m (Move page script moved page API pairs to WoW:API pairs without leaving a redirect)
 
(7 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Comes from the native LUA API:
{{wowlua}}
Returns an iterator triple that allows for loops to iterate over all key/value pairs in a table.
iteratorFunc, table, startState = pairs(table);


Used in loop constructs to iterate through the values of a table, with index beeing anything.
== Example ==
 
  local random_array = { mug = "coffee", [42] = "universe", testboolean = false }
Example:
 
  for index,value in pairs(random_array) do  
  local random_array = { mug = "coffee", [42] = "universe", true = "false" }
 
  for index,value in pairs(fruits) do  
   if (type(index) == "number") then
   if (type(index) == "number") then
       index = tostring(index)
       index = tostring(index)
Line 24: Line 23:
   mug : coffee
   mug : coffee
   42 : universe
   42 : universe
   true : false
   testboolean : false


would be output to the chat window.
would be output to the chat window.
----
{{template:WoW API}}
Anonymous user