title: Groovy for Rubyists - #each_slice
body: <p>In ruby I have #each_slice...</p>
  
  <pre><code>(1..10).each_slice(3).to_a
  =&gt; [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
  </code></pre>
  
  <p>I'm looking for an elegant way to do the same in Groovy and this is all I got so far as a beginner:</p>
  
  <pre><code>arr = []
  list = (1..10) as Queue
  while(!list.isEmpty()) {
  sub_arr = []
  3.times { sub_arr &lt;&lt; list.poll() }
      sub_arr.removeAll([null])
      arr &lt;&lt; sub_arr
  }
  arr
  Result: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
  </code></pre>