Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Any way to advance to an iterator prematurely?

Reply
Thread Tools

Any way to advance to an iterator prematurely?

 
 
Kurt Euler
Guest
Posts: n/a
 
      09-04-2003
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


 
Reply With Quote
 
 
 
 
Dan Doel
Guest
Posts: n/a
 
      09-04-2003
(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.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What makes an iterator an iterator? Steven D'Aprano Python 28 04-20-2007 03:34 AM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
Difference between Java iterator and iterator in Gang of Four Hendrik Maryns Java 18 12-22-2005 05:14 AM
How to convert from std::list<T*>::iterator to std::list<const T*>::iterator? PengYu.UT@gmail.com C++ 6 10-30-2005 03:31 AM
Iterator doubts, Decision on Iterator usage greg C++ 6 07-17-2003 01:26 PM



Advertisments