Bird
0
0

Identify the error in this Ruby code:

medium📝 Debug Q6 of 15
Ruby - Variables and Data Types
Identify the error in this Ruby code:
name = "Eve"
puts 'Hello, #{name}!'
ASingle quotes prevent interpolation, so #{name} is printed literally
BVariable name is not defined
CMissing closing quote
DInterpolation syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check string quotes

    The string uses single quotes which do not support interpolation.
  2. Step 2: Understand effect on output

    Because of single quotes, #{name} is printed as text, not replaced by variable value.
  3. Final Answer:

    Single quotes prevent interpolation, so #{name} is printed literally -> Option A
  4. Quick Check:

    Single quotes = no interpolation [OK]
Quick Trick: Use double quotes for interpolation, single quotes show text literally [OK]
Common Mistakes:
  • Expecting interpolation inside single quotes
  • Thinking variable is undefined
  • Confusing syntax error with output behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes