Instead of:
for current_iteration_number in 99..1 do
you can do:
for current_iteration_number in 99.downto(1) do
Pergunta
for current_iteration_number in 99..1 do
puts "#{current_iteration_number} of beer on the wall.
#{current_iteration_number} of beer. Take one down,
pass it around #{current_iteration_number} of beer."
end
Solução
Instead of:
for current_iteration_number in 99..1 do
you can do:
for current_iteration_number in 99.downto(1) do
Outras dicas
Ruby doesn't work like that for reverse ranges.
You should use some other way of doing it.
For instance:
99.downto(1).each do |current_iteration_number|
puts "#{current_iteration_number} of beer on the wall. #{current_iteration_number} of beer. Take one down, pass it around #{current_iteration_number} of beer."
end
You can do it like this too
a= 99..1
(a.first).downto(a.last).each do |current_iteration_number|
puts "#{current_iteration_number} of beer on the wall.
#{current_iteration_number} of beer. Take one down,
pass it around #{current_iteration_number} of beer.
end