Bird
0
0

Which statement about the Ruby loop method is true?

easy📝 Conceptual Q2 of 15
Ruby - Loops and Iteration
Which statement about the Ruby loop method is true?
AIt automatically stops after 10 iterations
BIt runs the block repeatedly until <code>break</code> is called
CIt requires a condition to stop the loop
DIt only runs the block once
Step-by-Step Solution
Solution:
  1. Step 1: Recall how loop works

    The loop method runs the block repeatedly without a built-in stop condition.
  2. Step 2: Understand stopping mechanism

    The loop continues until a break statement is executed inside the block.
  3. Final Answer:

    It runs the block repeatedly until break is called -> Option B
  4. Quick Check:

    Loop stops only with break = true [OK]
Quick Trick: loop runs forever unless break is used inside [OK]
Common Mistakes:
  • Assuming loop stops automatically after some iterations
  • Confusing loop with for or while loops
  • Thinking loop needs a condition argument

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes