Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a single-line comment in Swift.
Swift
[1] This is a comment Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using /* for single-line comments instead of //
Using # which is not a comment in Swift
✗ Incorrect
In Swift, single-line comments start with //.
2fill in blank
mediumComplete the code to start a multi-line comment in Swift.
Swift
[1] This is a
multi-line comment
*/ Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using // for multi-line comments
Using # which is not a comment in Swift
✗ Incorrect
Multi-line comments in Swift start with /* and end with */.
3fill in blank
hardFix the error in the documentation comment syntax.
Swift
[1] This function adds two numbers. func add(a: Int, b: Int) -> Int { return a + b }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of /// for documentation comments
Using /* or /** which are for multi-line comments
✗ Incorrect
In Swift, documentation comments use three slashes /// before the comment.
4fill in blank
hardFill both blanks to create a documentation comment with a parameter description.
Swift
[1] Adds two numbers. [2] - Parameter a: The first number.
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of /// for documentation
Using * instead of - for parameter description
✗ Incorrect
Documentation comments start with ///. Parameter descriptions use a dash - followed by the parameter name.
5fill in blank
hardFill all three blanks to complete the documentation comment with summary, parameter, and return description.
Swift
[1] Calculates the sum of two integers. [2] - Parameter x: The first integer. [3] - Returns: The sum of x and y.
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of /// for documentation lines
Missing dashes before parameter or return descriptions
✗ Incorrect
Documentation comments lines start with ///. Use a dash - before parameter and return descriptions.