Skip to main content
A multi-line comment in Swift is a lexical construct that instructs the compiler to ignore a specific block of text spanning one or more lines during the tokenization phase. It is defined using a forward-slash followed by an asterisk (/*) as the opening delimiter, and an asterisk followed by a forward-slash (*/) as the closing delimiter. Any characters placed between these delimiters are treated as whitespace by the Swift compiler.
Unlike many C-family languages, Swift supports nested multi-line comments. The compiler tracks the depth of the comment blocks, requiring every opening delimiter (/*) to be matched with a corresponding closing delimiter (*/) before the standard parsing of source code resumes.
Because the compiler evaluates the nesting depth, an inner */ will not prematurely terminate the outer /*. The lexical analyzer will only resume standard token generation once the nesting depth returns to zero.
Tired of Poor Swift Skills? Fix That With Deep Grasping!Learn More