Bird
0
0

Examine the following YARD comment and identify the issue:

medium📝 Debug Q6 of 15
Ruby - Ecosystem and Best Practices
Examine the following YARD comment and identify the issue:
# @param age [Integer] User's age
def set_age(age)
  @age = age
end
AThe comment should be placed after the method definition.
BThe parameter type '[Integer]' is invalid syntax in YARD.
CThe method name 'set_age' is not allowed in YARD documentation.
DThe comment uses a single '#' instead of double '##' for YARD to recognize it.
Step-by-Step Solution
Solution:
  1. Step 1: Review YARD comment syntax

    YARD requires documentation comments to start with '##' or '/**' to parse them.
  2. Step 2: Analyze the given comment

    The comment uses a single '#' which is treated as a normal comment, not a YARD doc comment.
  3. Final Answer:

    The comment uses a single '#' instead of double '##' for YARD to recognize it. -> Option D
  4. Quick Check:

    YARD needs '##' for doc comments. [OK]
Quick Trick: YARD doc comments start with '##' or '/**' [OK]
Common Mistakes:
  • Using single '#' instead of '##' for YARD comments
  • Misunderstanding YARD parameter type syntax
  • Placing comments after method definitions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes