The old documentation must have just been replace by the new one... The 
bigger problem is that the most recent one is still far the weakest part of 
the whole project, as it is laconic, incomplete, even faulty in some cases 
and it does not encourage any deeper understanding of the code base.  Just 
search for some keywords like 'error tickets / mistakes in the code base / 
in the documentation', and the like, and you will be quickly up-to date 
about it, but I will leave it now...

The need for using the $break object is based on how iteration is handled 
in Prototype in the 'each' method where any iterator functions are passed 
on to be called in the _each method in a  try- catch structure. 
In this way any errors in any bad function calls at any depth are caught by 
the high level catch branch.. Because the native boiler- plate iteration 
always only takes place in the high-level scope of the  _each method, you 
will get an error if you try to call the break command in an embedded 
method to try to step out of the high-level loop as there is no iteration 
taking place in that deeper scope, at all. Instead, Prototype throws a 
special error object to do exactly that.

In the any method - for instance- 
/*...cut...*/
    this.each(function(value, index) {
      if (result = !!iterator.call(context, value, index, this))
        throw $break;
    }, this);
/*...cut..*/
the $break object is thrown when the iterator function returns a boolean 
true value for the first element. The loop is broken and the result 
variable is returned. In the catch branch of each the special $break error 
object is recognized and evaluated to do nothing then.
catch (e) {
      if (e != $break) throw e;
    }


-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/0YxJECvdIr8J.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to