Recall & Review
beginner
What is the purpose of comments in Ruby code?
Comments explain what the code does. They help people understand the code later. Ruby ignores comments when running the program.
Click to reveal answer
beginner
How do you write a single-line comment in Ruby?
Use the # symbol before the comment text. Everything after # on that line is a comment.
Click to reveal answer
intermediate
What is a multi-line comment in Ruby and how is it written?
Ruby does not have a special multi-line comment syntax. Instead, you write multiple single-line comments starting each line with #.
Click to reveal answer
beginner
Why is documentation important in programming?
Documentation helps others and your future self understand how to use and maintain the code. It saves time and reduces mistakes.
Click to reveal answer
intermediate
What is a common way to document methods in Ruby?
Use comments above the method to describe what it does, its inputs, and outputs. This helps others know how to use the method.
Click to reveal answer
How do you start a single-line comment in Ruby?
✗ Incorrect
In Ruby, single-line comments start with the # symbol.
What happens to comments when Ruby code runs?
✗ Incorrect
Comments are ignored by Ruby when the program runs.
Which of these is NOT a reason to write comments?
✗ Incorrect
Comments do not affect how fast code runs; they only help with understanding.
How do you write multi-line comments in Ruby?
✗ Incorrect
Ruby uses multiple single-line comments starting with # for multi-line comments.
Where should you place documentation comments for a method?
✗ Incorrect
Documentation comments are usually placed above the method to describe it.
Explain how to write comments in Ruby and why they are useful.
Think about how you tell a friend what your code does without changing the code.
You got /4 concepts.
Describe best practices for documenting methods in Ruby.
Imagine you are writing instructions for someone else to use your method.
You got /4 concepts.