Bird
0
0

Which keyword in Swift is used to mark a function that can throw an error?

easy📝 Conceptual Q1 of 15
iOS Swift - Swift Language Essentials
Which keyword in Swift is used to mark a function that can throw an error?
Athrows
Btry
Ccatch
Dthrowing
Step-by-Step Solution
Solution:
  1. Step 1: Understand function declaration for error throwing

    Functions that can throw errors must be marked with the keyword throws after the parameter list.
  2. Step 2: Differentiate keywords

    try is used when calling a throwing function, catch is for handling errors, and throwing is not a valid keyword.
  3. Final Answer:

    throws -> Option A
  4. Quick Check:

    Function declaration uses throws = A [OK]
Quick Trick: Use 'throws' to declare error-throwing functions [OK]
Common Mistakes:
  • Confusing 'try' with 'throws'
  • Using 'throwing' instead of 'throws'
  • Using 'catch' in function declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes