Bird
0
0

Identify the error in this Ruby code snippet:

medium📝 Debug Q14 of 15
Ruby - Basics and Runtime
Identify the error in this Ruby code snippet:
  =begin
This is a multi-line comment
# Another comment line
  =end
puts "Done"
A=begin and =end must be at the start of the line
BThe # inside multi-line comment causes error
CMissing closing =end
DMulti-line comment syntax is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check multi-line comment syntax rules

    In Ruby, =begin and =end must be at the start of the line with no leading spaces.
  2. Step 2: Analyze the given code

    If =begin or =end are indented or not at line start, Ruby raises a syntax error.
  3. Final Answer:

    =begin and =end must be at the start of the line -> Option A
  4. Quick Check:

    Multi-line comment markers must start line [OK]
Quick Trick: =begin and =end must start the line exactly [OK]
Common Mistakes:
MISTAKES
  • Indenting =begin or =end
  • Thinking # inside multi-line comment causes error
  • Forgetting to close multi-line comment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes