Download

[BUG?] Function return value stops for each loops?

so I noticed that in my for each loop, the for each loop breaks when there is a return value. Is this normal? So if i have a for each loop with a return value, it wont iterate through the other array elements but will just return the first (instead of the last) and then stops the loop. How could I get multiple return values? It gave me alot of headaches as I thought for each loops would continiously loop (notice I am not using for each loop with break) but the standard for each loop.

Is anyone able to tell me if that is expected?

Functions are built to exit the first time you call the return node. It would make no sense if the function was sending back values after you code had already carried on…

If you want to return more than one thing, you need to return an array.

As @ClockworkOcean notes Functions stop execution on return of a result.

If you need to iterate through the entire array you need to call an event or function to process the data in the loop body and only call return on finished.