WoW:API next: Difference between revisions

Added "Changing values of existing keys or removing keys is alright though."
No edit summary
(Added "Changing values of existing keys or removing keys is alright though.")
Line 1: Line 1:
<b><tt>next (table, [index])</tt></b>
Native Lua statement:
 
next (table, [index])


Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. <b><tt>next</tt></b> returns the next index of the table and the value associated with the index. When called with nil as its second argument, <b><tt>next</tt></b> returns the first index of the table and its associated value. When called with the last index, or with nil in an empty table, <b><tt>next</tt></b> returns nil. If the second argument is absent, then it is interpreted as nil.
Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. <b><tt>next</tt></b> returns the next index of the table and the value associated with the index. When called with nil as its second argument, <b><tt>next</tt></b> returns the first index of the table and its associated value. When called with the last index, or with nil in an empty table, <b><tt>next</tt></b> returns nil. If the second argument is absent, then it is interpreted as nil.
Line 7: Line 9:




The behavior of <b><tt>next</tt></b> is undefined if, during the traversal, you assign any value to a non-existent field in the table.
The behavior of <b><tt>next</tt></b> is undefined if, during the traversal, you assign any value to a non-existent field in the table. Changing values of existing keys or removing keys is alright though.


----
{{LUA}}
{{template:WoW API}}
Anonymous user