Skip to content

Instantly share code, notes, and snippets.

@cato
Created March 23, 2011 01:17
Show Gist options
  • Select an option

  • Save cato/882449 to your computer and use it in GitHub Desktop.

Select an option

Save cato/882449 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
a = (1..16).to_a
# without each_slice
a.each do |i|
puts i.to_s
if i % 4 == 0 then
puts ','
end
end
# with each_slice
a.each_slice(4) {|a| puts a.to_s }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment