Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

each_slice (See related posts)

   1  
   2  require 'enumerator'
   3  
   4  (1..10).each_slice(2) { |n| p n }
   5  # [1, 2]
   6  # [3, 4]
   7  # [5, 6]
   8  # [7, 8]
   9  # [9, 10]

You need to create an account or log in to post comments to this site.


Click here to browse all 5349 code snippets

Related Posts