Or, if there's a situation where any() or all() doesn't suit, you can break each() loops by throwing $break. -- T.J. Crowder tj / crowder software / com
On Oct 9, 10:04 am, Tomasz Kalkosiński <[EMAIL PROTECTED]> wrote: > Nah! I've just discovered Enumerable.any() and Enumerable.all(). That > should do the trick. > > Sorry for hassle <o> > > Greetings, > Tomasz Kalkosiński > > On Oct 9, 10:47 am, Tomasz Kalkosiński <[EMAIL PROTECTED]> > wrote: > > > I'm refactoring old code and I use Enumerable.each() wherever > > possible. I've came to problem like this: > > > function checkSomething (arr) > > for (i=0 ; i < arr.length ; i++) { > > var c = arr[i]; > > if (c == 15) return true; > > } > > return false; > > > } > > > My question is can I do "short-circuit" return from inside > > each( function (c) {...} ) ? When I do return it's just like old throw > > $continue and it's not what I mean. > > > Greetings, > > Tomasz Kalkosiński > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---