Ruby - Loops and Iteration
What will be the output of this Ruby code?
count = 0
while count < 3
count += 1
if count == 2
redo
end
puts count
endcount = 0
while count < 3
count += 1
if count == 2
redo
end
puts count
endcount == 2, redo repeats the current iteration without incrementing count.count is not incremented again inside the loop, it stays 2, causing infinite repeats printing 2.redo repeats iteration without changing variables [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions