Tobias Haagen Michaelsen
2007-Feb-23 11:23 UTC
SV: [Rails-spinoffs] how to break some_hash.each(iterator) ?
Maybe you should not be using an iterator if you are just looking for one
specific value. The find()/detect() method might be more appropriate:
var el = this.regexps.find(function(p) { return value.match(p.value); });
if (el) {
this.current = el.value;
$(''where'').update(''in \'''' +
el.key + ''\'''');
}
-Tobias
-----Oprindelig meddelelse-----
Fra: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-spinoffs@googlegroups.com] På vegne af toapole maktonk
Sendt: 23. februar 2007 10:06
Til: Ruby on Rails: Spinoffs
Emne: [Rails-spinoffs] how to break some_hash.each(iterator) ?
Hello
I need to exit iterator when some condition finded:
this.regexps.each(
function(pair) {
if (value.match(pair.value)) { // pair.value is a RegExp object
this.current = pair.value;
$(''where'').update(''in \'''' +
pair.key + ''\'''');
// return; break; ? or how?
}
}
);
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Thanks! On Feb 23, 2:23 pm, "Tobias Haagen Michaelsen" <t...-GhZjJAf4V71knbxzx/v8hQ@public.gmane.org> wrote:> Maybe you should not be using an iterator if you are just looking for one specific value. The find()/detect() method might be more appropriate: > > var el = this.regexps.find(function(p) { return value.match(p.value); }); > if (el) { > this.current = el.value; > $(''where'').update(''in \'''' + el.key + ''\''''); > > } > > -Tobias > > -----Oprindelig meddelelse----- > Fra: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs@googlegroups.com] På vegne af toapole maktonk > Sendt: 23. februar 2007 10:06 > Til: Ruby on Rails: Spinoffs > Emne: [Rails-spinoffs] how to break some_hash.each(iterator) ? > > Hello > > I need to exit iterator when some condition finded: > > this.regexps.each( > function(pair) { > if (value.match(pair.value)) { // pair.value is a RegExp object > this.current = pair.value; > $(''where'').update(''in \'''' + pair.key + ''\''''); > // return; break; ? or how? > } > } > );--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---