Skip to content

Instantly share code, notes, and snippets.

@sadah
Created November 24, 2012 06:45
Show Gist options
  • Save sadah/4138687 to your computer and use it in GitHub Desktop.
Save sadah/4138687 to your computer and use it in GitHub Desktop.
each_slice
# こんな感じのコードが
ary = (1..100).to_a
while ary.size != 0
p ary.slice!(0,15)
end
# こんな感じに書ける。
(1..100).to_a.each_slice(15){|a| p a}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment