Chunk Array

Split an array into smaller chunks of a specified size.

Code

General
arr.each_slice(size).to_a

Parameters

Array to chunk

Size of each chunk

Server

More Ruby Snippets