m
Move page script moved page API foreachi to WoW:API foreachi without leaving a redirect
mNo edit summary |
m (Move page script moved page API foreachi to WoW:API foreachi without leaving a redirect) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{luaapi}} | ||
From [http://lua-users.org/wiki/TableLibraryTutorial TableLibraryTutorial] of lua-users.org. | From [http://lua-users.org/wiki/TableLibraryTutorial TableLibraryTutorial] of lua-users.org. | ||
table.foreachi(table, f) | table.foreachi(table, f) | ||
foreaci(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. | 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. | ||
| Line 28: | Line 29: | ||
In the above, it starts at t[1] (''not'' t[0]) and counts to t[3], printing the corresponding values along the way. It then checks t[4], sees it is nil, and stops running. t[5] is never checked - this ''will not hit every array index in a table, only the consecutive ones from one up until it hits its first blank index.'' | In the above, it starts at t[1] (''not'' t[0]) and counts to t[3], printing the corresponding values along the way. It then checks t[4], sees it is nil, and stops running. t[5] is never checked - this ''will not hit every array index in a table, only the consecutive ones from one up until it hits its first blank index.'' | ||