is there some way to break out of goog.array.forEach() ?
Thankyou
Nathan
var stop = Error();
function func(n) {
if (n > 3) {
throw stop;
}
...
}
try {
goog.array.forEach([0, 1, 2, 3, 4, 5], func);
} catch (ex) {
if (ex !== stop) {
throw ex;
}
}
As you can see this is a lot of boiler plate code and if you have an
array it seems simpler to use a for loop. You might also want to take
a look at what goog.iter has to offer. It allows you to write:
goog.iter.forEach([0, 1, 2, 3, 4, 5], function(n) {
if (n > 3) {
throw goog.iter.StopIteration;
}
...
});
--
erik
that was great advice!!
Good point. I hadn't considered exception handling.
Nathan