You’ve made it to the end of the sixth part of this series, so let’s summarize:
- You can assign closures to variables, then call them later on.
- Closures can accept parameters and return values, like regular functions.
- You can pass closures into functions as parameters, and those closures can have parameters of their own and a return value.
- If the last parameter to your function is a closure, you can use trailing closure syntax.
- Swift automatically provides shorthand parameter names like
$1, but not everyone uses them.
- If you use external values inside your closures, they will be captured so the closure can refer to them later.
Master iOS 11 now!
My book Practical iOS 11 gives you seven complete coding projects that teach all the major new features in iOS 11 in a smart, practical way.