Created
April 1, 2014 23:23
-
-
Save bswinnerton/9925082 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
99.downto(1) do |i| | |
puts "#{i} #{i.between?(2,99) ? "bottles" : "bottle"} of beer on the wall" | |
puts "#{i} #{i.between?(2,99) ? "bottles" : "bottle"} bottles of beer!" | |
puts "You take one down and pass it around," | |
puts "#{i} #{i.between?(2,99) ? "bottles" : "bottle"} bottles of beer on the wall!" | |
puts 'No more bottles of beer on the wall :-(' if i == 1 | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where
i.between?(2,99) ? "bottles" : "bottle"
evaluates to:This is known as a "ternary".