Reprisal
11/7/2006 6:42:00 PM
you could drop the unless and the final line. ( num = 1, num-1 = 0 ;)
99.downto( 1 ) do |num|
puts
puts "#{num} bottles of beer on the wall, #{num} bottles of beer,"
puts "take one down, pass it around,"
puts "#{num-1} bottles of beer on the wall"
end
Altho I think the book hasn't covered the enumeration type stuff yet
like downto.
On Nov 7, 2006, at 1:15 PM, Phrogz wrote:
> Phrogz wrote:
>> 99.downto( 1 ) do |num|
>> puts "#{num} bottles of beer on the wall, #{num} bottles of beer,"
>> puts "take one down, pass it around,"
>> end
>> puts '0,Bottles of beer on the wall ;)'
>
> Oops, I am, of course, missing one line of the song, and a nice
> newline
> for breaks. Should be more like:
>
> 99.downto( 1 ) do |num|
> puts
> puts "#{num} bottles of beer on the wall, #{num} bottles of beer,"
> puts "take one down, pass it around,"
> puts "#{num-1} bottles of beer on the wall" unless num == 1
> end
> puts '0 bottles of beer on the wall ;)'
>
>