Returns the function next followed by a table. |
||
Syntax |
f, T = pairs(T) |
|
Argument |
Name |
Description |
|
T |
A table to iterate. |
Outputs |
Name |
Description |
|
f |
A function. Returns the function next followed by a table. |
|
T |
A table; same table as the input. |
Example |
Syntax |
|
|
t = {'a','b',1,true,'c',false,'d'} t(23) = 'hyper' t.myfield = 'math' for key,value in pairs(t) do print(key,value) end |
|
|
Result |
|
|
1 a 2 b 3 1 4 true 5 c 6 false 7 d 23 hyper myfield math |
|
Comments |
'pairs' iterates over all key-value pairs. This function is usually used with a 'for' loop . |
|
See Also: |