Skip to content

Instantly share code, notes, and snippets.

@zackn9ne
Last active August 29, 2015 14:01
Show Gist options
  • Save zackn9ne/8ce2ca35b4b87f0add6e to your computer and use it in GitHub Desktop.
Save zackn9ne/8ce2ca35b4b87f0add6e to your computer and use it in GitHub Desktop.
Basic ruby loop
colors = ["blue","green","seafoam"]
colors.each do |color|
puts "I love #{color.upcase}!"
end
even more simple...
[1, 2, 3].each do |item|
puts("Iterating over #{item}...")
end
puts
more advanced example----------------------------------------
colors.each { |color| puts "I love #{color.upcase}!"
puts
working = colors
working.length.times do
puts "I love #{working.shift.upcase}!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment