title: next versus if in a .each loop?
body: <p>I have a text processing thing I'm doing in Ruby. Basically, I have to implement a simple state machine (with one character look-behind).</p>
  
  <p>My code at the moment looks like this:</p>
  
  <pre><code>text.each{ |c|
    ...
    ...
    ...
    ...
    if @state!=:some_state
      next
    end
    #processing stuff for if in :some_state mode
    ...
    ...
    ...
    ...
    ...
  }
  </code></pre>
  
  <p>Is this proper? Or should it rather be implemented like:</p>
  
  <pre><code>text.each{ |c|
    ...
    ...
    ...
    ...
    if @state==:some_state
      #processing stuff for if in :some_state mode
      ...
      ...
      ...
      ...
      ...
    end
  }
  </code></pre>
  
  <p>Is there a right way or is it just preference? Which one blends more with "the ruby way" of doing things?</p>