0
0
Swiftprogramming~10 mins

Comments and documentation markup in Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A/*
B#
C<!--
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using /* for single-line comments instead of //
Using # which is not a comment in Swift
2fill in blank
medium

Complete 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'
A//
B/*
C#
D<!--
Attempts:
3 left
💡 Hint
Common Mistakes
Using // for multi-line comments
Using # which is not a comment in Swift
3fill in blank
hard

Fix 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'
A/*
B//
C///
D/**
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of /// for documentation comments
Using /* or /** which are for multi-line comments
4fill in blank
hard

Fill 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'
A///
B//
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of /// for documentation
Using * instead of - for parameter description
5fill in blank
hard

Fill 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'
A///
B-
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of /// for documentation lines
Missing dashes before parameter or return descriptions