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.
12969 users tagging and storing useful source code snippets
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
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.