Bird
0
0

Which of the following is the correct way to write a compound case in Swift?

easy📝 Syntax Q3 of 15
Swift - Control Flow

Which of the following is the correct way to write a compound case in Swift?

switch day {
case "Mon" ___ "Tue":
    print("Start of week")
default:
    print("Other day")
}
A,
B|
C||
D&
Step-by-Step Solution
Solution:
  1. Step 1: Recall compound case separator

    Swift uses commas to separate multiple values in a single case.
  2. Step 2: Verify other symbols are invalid

    Symbols like |, ||, & are not used for compound cases in Swift.
  3. Final Answer:

    Use a comma to separate values in compound cases -> Option A
  4. Quick Check:

    Compound case separator = comma [OK]
Quick Trick: Separate values with commas in compound cases [OK]
Common Mistakes:
  • Using logical OR symbols instead of commas
  • Using bitwise AND symbol
  • Confusing with other languages' syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes