Ruby - Loops and Iteration
Identify the problem in this Ruby code snippet:
for i in 1..3
if i == 2
break
else
next
end
puts i
endfor i in 1..3
if i == 2
break
else
next
end
puts i
endnext skips to next iteration, break exits loop.i == 2, loop breaks; for others, next skips puts i.puts i is never executed because next skips it and break exits before it.puts i is unreachable. -> Option C15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions