Created
October 7, 2011 06:47
-
-
Save wycats/1269629 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment