There are many ways to perform a decrementing loop in Ruby:
First way:
for i in (10).downto(0)
puts i
end
Second way:
(10).downto(0) do |i|
puts i
end
Third way:
i=10;
until i<0
puts i
i-=1
end
There are many ways to perform a decrementing loop in Ruby:
First way:
for i in (10).downto(0)
puts i
end
Second way:
(10).downto(0) do |i|
puts i
end
Third way:
i=10;
until i<0
puts i
i-=1
end