Bird
0
0

Find the error in this Ruby code snippet:

medium📝 Debug Q6 of 15
Ruby - Control Flow

Find the error in this Ruby code snippet:

if x > 10
  puts "Big"
elsif x > 5
  puts "Medium"
else
  puts "Small"
AMissing parentheses around conditions
BIncorrect use of elsif instead of else if
CMissing end keyword to close if block
DUsing puts inside if block is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check Ruby syntax for if blocks

    Every if block must end with end.
  2. Step 2: Identify missing end

    The code snippet lacks end at the end.
  3. Final Answer:

    Missing end keyword to close if block -> Option C
  4. Quick Check:

    Ruby if blocks require end keyword = A [OK]
Quick Trick: Always close if blocks with end [OK]
Common Mistakes:
  • Forgetting end keyword
  • Using else if instead of elsif
  • Adding unnecessary parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes