Bird
0
0

What is a closure in Swift?

easy📝 Conceptual Q11 of 15
iOS Swift - Swift Language Essentials
What is a closure in Swift?
func greet() { print("Hello") }
AAn unnamed block of code that can be stored and passed around
BA named function that cannot be reused
CA variable that holds a number
DA type of loop
Step-by-Step Solution
Solution:
  1. Step 1: Understand closure definition

    A closure is a block of code without a name that can be saved and used later.
  2. Step 2: Compare with function

    Functions have names, closures do not but both can be reused.
  3. Final Answer:

    An unnamed block of code that can be stored and passed around -> Option A
  4. Quick Check:

    Closure = unnamed reusable code block [OK]
Quick Trick: Closures are like functions without names [OK]
Common Mistakes:
  • Confusing closures with variables
  • Thinking closures must have names
  • Mixing closures with loops

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes