Bird
0
0

Which of the following is the correct syntax to explicitly continue to the next case in a Swift switch?

easy📝 Syntax Q12 of 15
Swift - Control Flow
Which of the following is the correct syntax to explicitly continue to the next case in a Swift switch?
AUse the keyword <code>continue</code> inside the case.
BNo syntax needed; Swift does it automatically.
CUse the keyword <code>fallthrough</code> inside the case.
DUse a comma <code>,</code> between cases.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the keyword for fallthrough

    Swift uses the keyword fallthrough to continue to the next case.
  2. Step 2: Eliminate incorrect options

    continue is for loops, commas separate cases but don't cause fallthrough, and Swift does not do it automatically.
  3. Final Answer:

    Use the keyword fallthrough inside the case. -> Option C
  4. Quick Check:

    Explicit fallthrough keyword = fallthrough [OK]
Quick Trick: Use fallthrough keyword to continue to next case in Swift switch [OK]
Common Mistakes:
  • Confusing fallthrough with continue
  • Using commas to join cases expecting fallthrough
  • Assuming automatic fallthrough without keyword
  • Using break to continue to next case

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes