ForEach()
On this page
ForEach(collection_value: Variant, callback: Callable) -> intVisit array values or dictionary key/value pairs through a Callable.
Returns: Number of entries processed.
ForEach(["key", "note"], func(value, index): print(index, value))Array callback gets value,index. Dictionary callback gets key,value,index. Packed arrays are not handled by this helper. It does not await callbacks.
WhileLoop()#
WhileLoop(condition: Callable, body: Callable, safety_limit: int = 100000) -> intCheck a Callable condition before each Callable body pass.
Returns: Number of iterations.
WhileLoop(func(i): return i < 3, func(i): print(i))Both receive the current index. Safety limit prevents unbounded helper iterations; it does not make blocking work asynchronous.
ForLoop()#
ForLoop(count: int, body: Callable) -> intCall a body with indices 0 through count-1.
Returns: Number of completed passes.
ForLoop(3, func(i): print(i))Negative counts produce no passes. For asynchronous work, prefer an ordinary GDScript for loop with await in its body.
