Bird
0
0

In Swift, when are semicolons required at the end of statements?

easy📝 Conceptual Q11 of 15
Swift - Variables and Constants
In Swift, when are semicolons required at the end of statements?
ANever, semicolons are not used in Swift
BAlways at the end of every statement
COnly after function declarations
DOnly when multiple statements are on the same line
Step-by-Step Solution
Solution:
  1. Step 1: Understand Swift statement endings

    Swift allows statements to end without semicolons if each is on its own line.
  2. Step 2: Identify when semicolons are necessary

    Semicolons are needed only to separate multiple statements on the same line.
  3. Final Answer:

    Only when multiple statements are on the same line -> Option D
  4. Quick Check:

    Semicolons required = multiple statements on one line [OK]
Quick Trick: Semicolons separate statements on the same line only [OK]
Common Mistakes:
  • Thinking semicolons are always required
  • Believing semicolons are needed after every statement
  • Assuming semicolons are never used

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes