Any way to advance to an iterator prematurely?

Discussion in 'Ruby' started by Kurt Euler, Sep 4, 2003.

  1. Kurt Euler

    Kurt Euler Guest

    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
     
    Kurt Euler, Sep 4, 2003
    #1
    1. Advertising

  2. Kurt Euler

    Dan Doel Guest

    (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.
    >
    >
     
    Dan Doel, Sep 4, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Hsieh

    cache expiring prematurely

    Tony Hsieh, Aug 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    475
    Mark Fitzpatrick
    Aug 19, 2004
  2. =?Utf-8?B?RG9uYWxkIFNjb3R0?=

    Session ending prematurely - Forms Authentication

    =?Utf-8?B?RG9uYWxkIFNjb3R0?=, Jul 15, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    549
    =?Utf-8?B?RG9uYWxkIFNjb3R0?=
    Jul 20, 2005
  3. tshad

    dbReader closing prematurely

    tshad, Jan 11, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,038
    tshad
    Jan 11, 2006
  4. DC
    Replies:
    4
    Views:
    674
  5. mantarraya
    Replies:
    2
    Views:
    1,376
    Andrew Thompson
    Aug 5, 2004
Loading...

Share This Page