> I really prefer doing a 'return false' instead of throwing exceptions.
> It just feels like an incredibly messy way to handle things - 
> plus it prevents you from writing good one-liners, which makes me sad.
> 
> Plus the change is trivial, too:
> 
>         each: function( obj, fn, args ) {
>                 if ( obj.length == undefined )
>                         for ( var i in obj )
>                                 if ( fn.apply( obj[i], args || [i, obj[i]]
) === false ) return obj;
>                 else
>                         for ( var i = 0; i < obj.length; i++ )
>                                 if ( fn.apply( obj[i], args || [i, obj[i]]
) === false ) return obj;
>                 return obj;
>         },
> 
> Should I add it in?

I'm all for using "return false".

Two suggestions:

1) Change the first two "return obj"s to breaks.

2) Put some curly braces in that code! It is scary the way it is.

        each: function( obj, fn, args ) {
                if ( obj.length == undefined ) {
                        for ( var i in obj )
                                if ( fn.apply( obj[i], args || [i, obj[i]] )
=== false )
                                        break;
                }
                else {
                        for ( var i = 0; i < obj.length; i++ )
                                if ( fn.apply( obj[i], args || [i, obj[i]] )
=== false )
                                        break;
                }
                return obj;
        },

-Mike


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

Reply via email to