Created
December 14, 2011 14:08
-
-
Save agentfin/1476700 to your computer and use it in GitHub Desktop.
Start from anywhere, 99bottles of beer song.
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
# 99 bottles of beer on the wall | |
# get a number of bottles | |
puts 'How many bottles do you have?' | |
bottles = gets.chomp.to_i | |
# set the loop to go til there are no more bottles | |
# we should be able to do this as an ".each do ||" | |
# but ruby has the hate today. | |
while bottles != 0 | |
# get the song going | |
puts "#{bottles} bottles of beer on the wall." | |
puts "#{bottles} bottles of beer!" | |
puts 'Take one down, pass it around.' | |
puts "#{bottles - 1} bottles of beer on the wall!" | |
# can drop the subtraction in at then end of the loop section | |
# -= is nice shorthand that doesnt require brackets or anything | |
bottles -= 1 | |
end | |
puts 'AND THEN WE ALL DRANK WHISKEY!!!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment