Bird
0
0

Identify the error in this YARD comment block:

medium📝 Debug Q14 of 15
Ruby - Ecosystem and Best Practices
Identify the error in this YARD comment block:
# @param name String the user's name
# @return String greeting message
def greet(name)
  "Hello, #{name}!"
end
AMissing square brackets around the type in @param and @return tags
BThe method name should be capitalized
CYARD comments must be placed after the method definition
DThe string interpolation syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check YARD tag syntax

    YARD requires types in square brackets, e.g., [String], not just String.
  2. Step 2: Verify other parts

    Method name capitalization and comment placement are correct; string interpolation is valid Ruby.
  3. Final Answer:

    Missing square brackets around the type in @param and @return tags -> Option A
  4. Quick Check:

    [Type] -> YARD requirement [OK]
Quick Trick: Always put types in square brackets in YARD tags [OK]
Common Mistakes:
  • Omitting square brackets around types
  • Placing comments after method instead of before
  • Confusing Ruby syntax errors with documentation errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes