title: When to use `each` and when to use the `for` loop in Groovy
body: <p>When do we use the <code>each</code> closure and when do we use the <code>for</code> loop in Groovy. Both effectively do the same thing.</p>
  
  <pre><code>groovy:000&gt; a = [1, 2, 3, 4]
  ===&gt; [1, 2, 3, 4]
  groovy:000&gt; a.each {
  groovy:001&gt; println it
  groovy:002&gt; }
  1
  2
  3
  4
  ===&gt; [1, 2, 3, 4]
  groovy:000&gt; for (it in a) {
  groovy:001&gt; println it
  groovy:002&gt; }
  1
  2
  3
  4
  ===&gt; null
  </code></pre>
  
  <p>The <code>each</code> closure returns the list. So I can probably use it instead of the <code>for</code> loop but not vice versa, correct?</p>