• Foreach works like so:
local tbl = {1, 2, 3}
foreach (k, v, tbl) {
        print(k, v)

  • prints: 1 1 2 2 3 3
  • The arguments are keyname, valuename and the iteration object if you have a custom class and want to support foreach, then all you need to do is add a method called NextKey, and return the indexing key for the next entry. After NextKey is called, the get index operator [] is called with the returned key. return null if the end of the object has been reached