[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Any way to advance to an iterator prematurely?

Kurt Euler

9/4/2003 7:21:00 AM

All-

In the code below, is there an way to put a condition just before <do a big bunch of stuff?> that will cause the iterator to advance to the next x (the next line in control.txt) WITHOUT doing <do a big bunch of stuff>. I thinking something like "if field[0] != "test" read_next_line_in_file". I'd
rather not put <do a big bunch of stuff> in a giant if/end statement.



IO.foreach("control.txt") { |x|
field = x.chop.split('\t', -1)
<do a big bunch of stuff?>
}



Thanks!

-Kurt


1 Answer

Dan Doel

9/4/2003 7:29:00 AM

0

(1..30).each do |x|
next if x == 15
puts x
end

Kurt Euler wrote:

>All-
>
>In the code below, is there an way to put a condition just before <do a big bunch of stuff?> that will cause the iterator to advance to the next x (the next line in control.txt) WITHOUT doing <do a big bunch of stuff>. I thinking something like "if field[0] != "test" read_next_line_in_file". I''d
>rather not put <do a big bunch of stuff> in a giant if/end statement.
>
>