Jones 36 Report post Posted April 15, 2016 what does in pairs mean? for [xxx] in pairs, do Quote Share this post Link to post Share on other sites
Billy 164 Report post Posted April 15, 2016 essentially, lua tables save the index and the value. eg array["index"] = value Item[27] = 855 Item["new"] = "hello" eg for i,v in pairs(Item) do print(i.." "..v) end Would output 27 855 new hello 1 Quote Share this post Link to post Share on other sites
MonkeyCode 453 Report post Posted April 15, 2016 (edited) for is one of three traditional loops (for, do, while) why use pairs instead of numeric loop (for i = 0, 5 do {...})? Arrays in LUA are tables that are dynamic in terms of data structures. (lists, dictionary, arrays, etc.) Example: t[1] = 5; t['one'] = 5; -- in C, t['one'] is not a valid usage of arrays. we start using keyword 'pairs' when the indexes are not numerical and want to iterate through a table. Edited April 15, 2016 by xtc 1 Quote Share this post Link to post Share on other sites
Jones 36 Report post Posted April 22, 2016 @xtc @7n6 Very helpful. Thanks for the information! Quote Share this post Link to post Share on other sites