Bird
0
0

Identify the error in this Ruby code:

medium📝 Debug Q14 of 15
Ruby - Control Flow
Identify the error in this Ruby code:
puts "Done" unless
AIncorrect use of puts
BMissing condition after unless
CShould use if instead of unless
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check the inline unless syntax

    Inline unless requires a condition after it to decide when to run the code.
  2. Step 2: Analyze the given code

    The code ends with unless but no condition follows, causing a syntax error.
  3. Final Answer:

    Missing condition after unless -> Option B
  4. Quick Check:

    Inline unless must have a condition [OK]
Quick Trick: Always put a condition after unless [OK]
Common Mistakes:
  • Leaving out the condition after unless
  • Thinking puts usage is wrong
  • Confusing syntax error with runtime error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes