Beginner
Swift
Q14 / 100
What is a closure in Swift?
Correct! Well done.
Incorrect.
The correct answer is B) A self-contained block of code that captures values from its surrounding context
B
Correct Answer
A self-contained block of code that captures values from its surrounding context
Explanation
Closures in Swift are similar to lambdas. { (x: Int) -> Int in return x * 2 } can be shortened to { x in x * 2 } or even { $0 * 2 }.
Progress
14/100