Recall & Review
beginner
What is the purpose of comments in Swift code?
Comments explain the code to humans. They help others (and yourself) understand what the code does without affecting how the program runs.
Click to reveal answer
beginner
How do you write a single-line comment in Swift?
Use two slashes
// before the comment text. Everything after // on that line is ignored by the compiler.Click to reveal answer
beginner
How do you write a multi-line comment in Swift?
Start with
/* and end with */. Everything between is treated as a comment, even if it spans many lines.Click to reveal answer
intermediate
What is documentation markup in Swift and why is it useful?
Documentation markup uses special comment styles (like
///) to create structured notes. These notes can be shown in code editors to explain functions, parameters, and return values clearly.Click to reveal answer
intermediate
Give an example of a documentation comment for a Swift function.
/// Adds two numbers and returns the result. /// - Parameters: /// - a: The first number. /// - b: The second number. /// - Returns: The sum ofaandb.
Click to reveal answer
Which symbol starts a single-line comment in Swift?
✗ Incorrect
Single-line comments in Swift start with
//. Multi-line comments use /* ... */.What does the following Swift comment style
/// indicate?✗ Incorrect
/// is used for documentation comments that provide structured information about code elements.How do multi-line comments behave in Swift?
✗ Incorrect
Multi-line comments in Swift are enclosed between
/* and */.Why should you use documentation comments in your Swift code?
✗ Incorrect
Documentation comments improve code readability and help others (and yourself) understand how to use your code.
Which of these is NOT a valid Swift comment style?
✗ Incorrect
is an HTML comment style, not valid in Swift.Explain the difference between single-line, multi-line, and documentation comments in Swift.
Think about how each comment type looks and what it is used for.
You got /3 concepts.
Write a documentation comment for a Swift function that multiplies two numbers and returns the result.
Follow the Swift documentation comment format with clear sections.
You got /4 concepts.