Hey Dan,

Dan Webb a écrit :
> How would you implement this optionally?

A basic way:

  each: function(iterator, useBreak) {
     var index = 0;
     if (!useBreak)
       this._each(function(value) {
         iterator(value, index++);
       });
     else
       try {
         this._each(function(value) {
           iterator(value, index++);
         });
       } catch (e) {
         if (e != $break) throw e;
       }
     return this;
   },

Since we need to explicitely avoid the try/catch clause to gain speed, I 
don't see an obvious way to avoid duplication, except by factoring out 
the _each block in a separate methods, which I don't think is very much 
worth it.

-- 
Christophe Porteneuve aka TDD
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to