Bird
0
0

Identify the error in this Ruby heredoc code:

medium📝 Debug Q14 of 15
Ruby - String Operations
Identify the error in this Ruby heredoc code:
message = <
AThe string must be enclosed in quotes
BThe starting identifier should be lowercase
CThe heredoc must use <<~ instead of <<
DThe ending identifier must match exactly and be alone on its line
Step-by-Step Solution
Solution:
  1. Step 1: Check heredoc start and end identifiers

    Heredoc must end with the same identifier used to start it, alone on a line with no spaces.
  2. Step 2: Analyze given code

    Start identifier is GREETING but end identifier is END, which is incorrect.
  3. Final Answer:

    The ending identifier must match exactly and be alone on its line -> Option D
  4. Quick Check:

    Start and end identifiers must match [OK]
Quick Trick: End heredoc with the exact same word alone on a line [OK]
Common Mistakes:
MISTAKES
  • Mismatching start and end identifiers
  • Adding spaces after end identifier
  • Using lowercase instead of uppercase identifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes