WoW:API foreachi: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Use Lua/Libshortcut template. Change category from "LUA Functions" to "Lua functions".) |
||
Line 1: | Line 1: | ||
{{:Lua/Libshortcut|foreachi|table.foreachi}} | |||
From [http://lua-users.org/wiki/TableLibraryTutorial TableLibraryTutorial] of lua-users.org. | From [http://lua-users.org/wiki/TableLibraryTutorial TableLibraryTutorial] of lua-users.org. | ||
Line 13: | Line 14: | ||
Note in the example only the indexed elements of the table are displayed. See the TablesTutorial for more information on key-value and index-value pairs. | Note in the example only the indexed elements of the table are displayed. See the TablesTutorial for more information on key-value and index-value pairs. | ||
{{LUA}} | |||
{{ |
Revision as of 12:14, 26 May 2006
Lua/Libshortcut From TableLibraryTutorial of lua-users.org.
table.foreachi(table, f)
Apply the function f to the elements of the table passed. On each iteration the function f is passed the index-value pair of that element in the table. This is similar to table.foreach() except that index-value pairs are passed, not key-value pairs. If the function f returns a non-nil value the iteration loop terminates.
> t = { 1,2,"three"; pi=3.14159, banana="yellow" } > table.foreachi(t, print) 1 1 2 2 3 three
Note in the example only the indexed elements of the table are displayed. See the TablesTutorial for more information on key-value and index-value pairs.