Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Obviously this could be done with .join("\n"), but let's say we didn't have join...
x = [1,2,3,4]
# This will yield: 1,2 then 2,3 then 3,4 then 4,nil
(x + [nil]).each_cons(2) do |item, next_item|
puts item
puts "\n" if next_item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment