This is a case where we need to "reveal sudden cleverness".  I suggest
that if "return false" is the way to go (and, I do like it), then we
should make sure that if the logging plugin is used, or if the user is
using firebug or the MS deubgger at all, that there is a message in the
log clearly when each is broken by a "return false".  That way, anyone who
has to debug this doesn't get way too frustrated at not being able to find
what's stopping their loop.

As to "false" as a valid return value for multiple elements - maybe there
should be a parm to turn it off?

Something like:
$(".blap").each( function() { whatever... }, false );

Or, perhaps a parm to turn it *on*, since not breaking on false is the
default right now, and we can avoid busting people's code that way.

- Brian


> I too prefer returning a variable and false is fine by me. It'll just
> have to be documented so some programmer out there that returns false
> for some reason or another doesn't get really confused.
>
> An example would be a continue style situation:
> $("p").each(function() {
>     // skip this iteration but keep going through the set
>     if ($(this).is(".skip")) return false;
>     $(this).remove();
> });
>
> Someone innocently returning false, maybe to remind himself that it's
> not the expected outcome, would get quite flummoxed if this isn't
> documented.
>
> -blair
>
> John Resig wrote:
>> I really prefer doing a 'return false' instead of throwing exceptions.
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>



_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to