Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:API ipairs
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{luaapi}} Returns an iterator triple that allows the Lua for loop to iterate over the array portion of a table. iteratorFunc, table, startState = ipairs(table) == 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. Note that ipairs() starts at index 1 and stops counting as soon as it reaches a nil value. Example: > t = { [0] = "zero", --will not be counted [1] = "one", --will be counted; 1 [2] = "two", --will be counted; 2 [3] = "three", --will be counted; 3 ["four"] = "four", --will not be counted; returns 3 [5] = "five" } --will never be reached > for i,v in ipairs(t) do print(i..":"..v) end 1:one 2:two 3:three Note that t[0] is never reached because it starts counting at [1], t["four"] is never reached because it is not an array index, and t[5] is never reached because the iterator ceases when it checks t[4] and finds a nil value.
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Apinav
(
edit
)
Template:Editlink
(
edit
)
Template:Luaapi
(
edit
)
Template:Wowlua
(
edit
)