Bird
0
0

Which of the following is the correct syntax to define an enum case with an associated value of type String?

easy📝 Syntax Q12 of 15
iOS Swift - Swift Language Essentials
Which of the following is the correct syntax to define an enum case with an associated value of type String?
Acase name = String
Bcase name(String)
Ccase name: String
Dcase name -> String
Step-by-Step Solution
Solution:
  1. Step 1: Recall enum case syntax with associated values

    Use parentheses after the case name to specify the type of associated value.
  2. Step 2: Match correct syntax

    Only case name(String) uses parentheses correctly.
  3. Final Answer:

    case name(String) -> Option B
  4. Quick Check:

    Use parentheses for associated value types [OK]
Quick Trick: Use parentheses to declare associated value types [OK]
Common Mistakes:
  • Using colon instead of parentheses
  • Assigning value with equals sign
  • Using arrow notation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes