Bird
0
0

You want to document a method in Ruby so tools can generate documentation automatically. Which style should you use?

hard📝 Application Q8 of 15
Ruby - Basics and Runtime
You want to document a method in Ruby so tools can generate documentation automatically. Which style should you use?
AWrite comments after the method call
BUse # comments directly above the method
CUse =begin and =end inside the method
DWrite comments inside the method body
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby documentation conventions

    Ruby tools like RDoc use comments placed immediately before method definitions.
  2. Step 2: Identify correct placement

    Comments above the method with # are recognized for documentation.
  3. Final Answer:

    Use # comments directly above the method -> Option B
  4. Quick Check:

    Doc comments go above method with # [OK]
Quick Trick: Place # comments above methods for documentation [OK]
Common Mistakes:
  • Putting comments inside method body
  • Using multi-line comments inside method
  • Commenting after method calls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes