title: How to split (chunk) a Ruby array into parts of X elements?
body: <p>I have an array</p>
  
  <pre><code>foo = %w(1 2 3 4 5 6 7 8 9 10)
  </code></pre>
  
  <p>How can I split or "chunk" this into smaller arrays?</p>
  
  <pre><code>class Array
    def chunk(size)
      # return array of arrays
    end
  end
  
  foo.chunk(3)
  # =&gt; [[1,2,3],[4,5,6],[7,8,9],[10]]
  </code></pre>