Re: forEach break - couple of options
- Returning a TAFFY object makes sense, but maybe something like
TAFFY.exit or TAFFY.quit, since break is a reserved word.
If you return something like a string or false, couldn't it be
possible that is the value you want to return?
--- In firstname.lastname@example.org, "tacoman_cool" <ian@...> wrote:
> Matt requested a break option for forEach loops. I thought it was
> worth putting it on here in case anyone else had a comment. I can see
> a couple of different options to make this work.
> Option 1 - you break a forEachby returning text from your function:
> return "break";
> Option 2 - you break a forEach by returning a special function:
> return TAFFY.break;
> Option 3 - you break a forEach returning false from your function:
> return false;
> Right now if you return anything in a forEach it assumes that is a
> record and overwrites it in the collection via an update. We could
> make it so you could return any text and it would break, just the word
> break, false, or a special function that or Object. What makes the
> most sense and would cause the least confusion?
> Can any one else thing of a case where returning a special function or
> even a custom function from forEach would be useful beyond breaking?
> Is there any reason to return TAFFY.remove to remove the record you
> just looped over (for example)?