title: Ruby: What is the difference between a for loop and an each loop?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3294509/for-vs-each-in-ruby">for vs each in Ruby</a>  </p>
  </blockquote>
  
  
  
  <p>Let's say that we have an array, like</p>
  
  <p><code>sites = %w[stackoverflow stackexchange serverfault]</code></p>
  
  <p>What's the difference between</p>
  
  <pre><code>for x in sites do
    puts x
  end
  </code></pre>
  
  <p>and</p>
  
  <pre><code>sites.each do |x|
    puts x
  end
  </code></pre>
  
  <p>?</p>
  
  <p>They seem to do the same exact thing, to me, and the syntax of the <code>for</code> loop is clearer to me. Is there a difference? In what situations would this be a big deal?</p>