Iterates the given array and calls the given callable for each element.
If callable returns != 0, it will stop the iteration and return that value, otherwise it will return 0.
Use this instead of foreach when the array may expand during iteration.
the callable to call for each element
the array to iterate
the last value returned by callable
Array!int array; foreach (e ; [2, 3, 4, 5]) array.push(e); int[] result; const returnValue = array.each!((e) { result ~= e; if (e == 3) return 8; return 0; }); assert(result == [2, 3]); assert(returnValue == 8);
dmd.dsymbol.foreachDsymbol
See Implementation
Iterates the given array and calls the given callable for each element.
If callable returns != 0, it will stop the iteration and return that value, otherwise it will return 0.
Use this instead of foreach when the array may expand during iteration.