Skip to content

Instantly share code, notes, and snippets.

@jbuda
Created October 19, 2013 20:22
Show Gist options
  • Save jbuda/7061047 to your computer and use it in GitHub Desktop.
Save jbuda/7061047 to your computer and use it in GitHub Desktop.
Ruby - Day 2 - Seven Languages in Seven Weeks
# using each
values = []
[*(1..16)].each do |i|
values.push(i)
if (values.length == 4)
puts values.join(",")
values = []
end
end
# using each_slice
[*(1..16)].each_slice(4) do |i|
puts i.join(",")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment