function do_a_loop() { var fields = new Array(1,2,3,4); fields.each(function(item)) { if(item == 2){ return; } } } Im trying to do the following with prototype, but I need to exit the do_a_loop() function not just the function within each(). any ideas? I was originally using a (for in) loop until we moved to using prototype, now that we cannot use for in we have lost some functionality. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
try this var fields = [1,2,3,4]; fields.each( function( item ){ if( item == 2 ){ return;//this will skip "the rest of the code" for option 2 only } //the rest of the code } or this fields.each( function( item ){ if( item == 2 ){ throw $break;//this will end the each; } //the rest of the code } -- Edward Grant themasternone-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org RPGA #342155 CAMARILLA #US2002022579 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---