Bird
0
0

Identify the error in this Swift code snippet:

medium📝 Debug Q14 of 15
Swift - Basics and Runtime
Identify the error in this Swift code snippet:
/* This is a multi-line comment
func greet() {
    print("Hello")
}
// Missing closing comment delimiter
AUsing // inside multi-line comment is invalid
BMissing closing */ for multi-line comment
CFunction greet() is not declared properly
Dprint statement syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Check multi-line comment syntax

    Multi-line comments start with /* and must end with */ to close properly.
  2. Step 2: Identify missing closing delimiter

    The code has /* but no closing */, so the comment never ends, causing a syntax error.
  3. Final Answer:

    Missing closing */ for multi-line comment -> Option B
  4. Quick Check:

    Multi-line comment must close with */ [OK]
Quick Trick: Multi-line comments need /* and */ to open and close [OK]
Common Mistakes:
  • Ignoring missing closing comment delimiter
  • Thinking // can't be inside multi-line comments
  • Assuming function syntax is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes