[v] = ForEach(table, func[, userdata])
func
. The user function will receive two arguments: The first
argument will contain the index of the table element, whereas the second argument
will contain the value at that index. If the user function returns a value the loop
is broken, and this value is returned as the result from ForEach()
.
Please note that this function will traverse the whole table. If you would just like to iterate over integer indices, use the ForEachI() command instead. See ForEachI for details.
Starting with Hollywood 6.1 this function accepts an optional userdata
parameter.
The value you pass here will be forwarded to your callback as the third function
parameter. The value can be of any type.
t = {1, 2, 3, 4, Test$="Hello", Value=9.2} ForEach(t, DebugPrint)The code above dumps the contents of table 't' using
ForEach()
.