Last active
August 29, 2015 14:01
-
-
Save zackn9ne/8ce2ca35b4b87f0add6e to your computer and use it in GitHub Desktop.
Basic ruby loop
This file contains hidden or 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
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