Skip to content

Instantly share code, notes, and snippets.

@sur
Last active October 12, 2015 13:57
Show Gist options
  • Save sur/4036816 to your computer and use it in GitHub Desktop.
Save sur/4036816 to your computer and use it in GitHub Desktop.
array in groups
1.9.3p194 :001 > a = 1,2,3,4,5,6,6
=> [1, 2, 3, 4, 5, 6, 6]
1.9.3p194 :002 > a.methods.grep /groups/
=> [:in_groups_of, :in_groups]
1.9.3p194 :003 > a.in_groups(2)
=> [[1, 2, 3, 4], [5, 6, 6, nil]]
1.9.3p194 :004 > a.in_groups_of(2)
=> [[1, 2], [3, 4], [5, 6], [6, nil]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment