KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an array foo = %w(1 2 3 4 5 6 7 8 9 10) How can I split or "chunk" this into smaller arrays? class Array def chunk(size) # return array of arrays end end foo.chunk(3) # => [[1,2,3],[4,5,6],[7,8,9],[10]]
Tags (comma-separated)
Save Edits
Cancel