Recall & Review
beginner
What does the
await keyword do in Swift?It pauses the current function until the asynchronous function finishes and returns its result.
Click to reveal answer
beginner
How do you mark a Swift function as asynchronous?
By adding the
async keyword after the function's parameter list and before the return type.Click to reveal answer
beginner
Why do you need to use
await when calling an async function?Because async functions run asynchronously and
await tells Swift to wait for the result before continuing.Click to reveal answer
intermediate
Can you call an async function without
await in Swift?No, you must use
await to call an async function unless you handle it differently with tasks or concurrency APIs.Click to reveal answer
intermediate
What happens if you forget to use
await when calling an async function inside another async function?The code will not compile because Swift requires
await to handle asynchronous calls properly.Click to reveal answer
Which keyword do you use to wait for an async function to finish in Swift?
✗ Incorrect
The
await keyword pauses execution until the async function completes.How do you declare a function that can be awaited in Swift?
✗ Incorrect
The
async keyword goes after the parameter list and before the return type.What must you add before calling an async function inside another async function?
✗ Incorrect
You use
await to wait for the async function's result.If you call an async function without
await, what happens?✗ Incorrect
Swift requires
await to call async functions; otherwise, it won't compile.Which of these is a correct way to call an async function named
fetchData() inside an async function?✗ Incorrect
You use
await before the function call to wait for its result.Explain how and why you use
await when calling async functions in Swift.Think about waiting for a friend to finish before continuing your task.
You got /4 concepts.
Describe the syntax for declaring and calling an async function in Swift.
Remember the order: declare async, call with await.
You got /4 concepts.